mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-25 12:36:11 +03:00
CommandManager: argument splitting supports "multi word"
works with " and '
This commit is contained in:
parent
9775958012
commit
417802cbdf
@ -27,17 +27,26 @@ static TokenList split(const std::string& line)
|
||||
TokenList result;
|
||||
|
||||
size_t pos = 0;
|
||||
while (pos != line.length())
|
||||
while (pos < line.length())
|
||||
{
|
||||
while(line[pos] == ' ' and pos != line.length())
|
||||
++pos;
|
||||
|
||||
char delimiter = ' ';
|
||||
if (line[pos] == '"' or line[pos] == '\'')
|
||||
{
|
||||
delimiter = line[pos];
|
||||
++pos;
|
||||
}
|
||||
|
||||
size_t token_start = pos;
|
||||
|
||||
while((line[pos] != ' ' or line[pos-1] == '\\') and pos != line.length())
|
||||
while((line[pos] != delimiter or line[pos-1] == '\\') and pos != line.length())
|
||||
++pos;
|
||||
|
||||
result.push_back(std::make_pair(token_start, pos));
|
||||
|
||||
++pos;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user