1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-25 20:41:49 +03:00

src: Don't escape completion candidates with \

Completion candidates are currently escaped with a backslash `\`
character, which leads to ugly interactive commands on the prompt,
especially when they contain space characters.

This commit makes completion candidates be escaped by simple quoting.

Examples:

    candidate\ with\ spaces
    \%opt{foo}
    \"dquote
    \'quote

become:

    'candidate with spaces'
    '%opt{foo}'
    '"dquote'
    '''quote'
This commit is contained in:
Frank LENORMAND 2020-03-12 22:02:22 +03:00
parent 6766297623
commit 7b28e68d6c

View File

@ -758,7 +758,9 @@ Completions CommandManager::complete(const Context& context,
if (not (completions.flags & Completions::Flags::Quoted) and token.type == Token::Type::Raw)
{
for (auto& c : completions.candidates)
c = (not c.empty() and contains("%'\"", c[0]) ? "\\" : "") + escape(c, "; \t", '\\');
c = (not c.empty() and c[0] == '%') or
any_of(c, [](auto i) { return contains("; \t'\"", i); }) ?
format("'{}'", replace(c, "'", "''")) : c;
}
return completions;