Fix auto escaping of command argument completion

This commit is contained in:
Maxime Coste 2018-06-23 12:43:06 +10:00
parent 51cff07821
commit 6a31d0ebc7

View File

@ -676,11 +676,10 @@ Completions CommandManager::complete(const Context& context,
context, flags, params, tokens.size() - 2, context, flags, params, tokens.size() - 2,
cursor_pos_in_token), start); cursor_pos_in_token), start);
if (not completions.quoted and token.type != Token::Type::RawQuoted) if (not completions.quoted and token.type == Token::Type::Raw)
{ {
StringView to_escape = token.type == Token::Type::Raw ? "% \t;" : "%"; for (auto& c : completions.candidates)
for (auto& candidate : completions.candidates) c = (not c.empty() and contains("%'\"", c[0]) ? "\\" : "") + escape(c, "; \t", '\\');
candidate = escape(candidate, to_escape, '\\');
} }
return completions; return completions;