CommandManager: Use byte rather than columns for token positions

Not only are display columns rarely used to give error positions,
but they make the parsing much slower as for each token we need to
compute the column in the line.
This commit is contained in:
Maxime Coste 2018-02-09 20:30:33 +11:00
parent 39c0c03351
commit b7a3d80bde
2 changed files with 6 additions and 6 deletions

View File

@ -85,9 +85,9 @@ public:
return {};
}
DisplayCoord coord() const
BufferCoord coord() const
{
return {line, utf8::column_distance(line_start, pos)};
return {line, (int)(pos - line_start)};
}
StringView str;
@ -432,7 +432,7 @@ CommandManager::find_command(const Context& context, StringView name) const
void CommandManager::execute_single_command(CommandParameters params,
Context& context,
const ShellContext& shell_context,
DisplayCoord pos)
BufferCoord pos)
{
if (params.empty())
return;
@ -481,7 +481,7 @@ void CommandManager::execute(StringView command_line,
// Tokens are going to be read as a stack
std::reverse(tokens.begin(), tokens.end());
DisplayCoord command_coord;
BufferCoord command_coord;
Vector<String> params;
while (not tokens.empty())
{

View File

@ -57,7 +57,7 @@ struct Token
Type type;
ByteCount begin;
ByteCount end;
DisplayCoord coord;
BufferCoord coord;
String content;
};
@ -99,7 +99,7 @@ private:
void execute_single_command(CommandParameters params,
Context& context,
const ShellContext& shell_context,
DisplayCoord pos);
BufferCoord pos);
struct Command
{