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

Fix switch completion

This commit is contained in:
Maxime Coste 2022-05-30 19:27:18 +10:00
parent d9ea62666b
commit ac6f928ad4

View File

@ -760,15 +760,15 @@ Completions CommandManager::complete(const Context& context,
auto& command = command_it->value;
auto is_switch = [](StringView s) { return s.substr(0_byte, 1_byte) == "-"; };
const bool has_switches = not command.param_desc.switches.empty();
auto is_switch = [=](StringView s) { return has_switches and s.substr(0_byte, 1_byte) == "-"; };
if (is_switch(token.content))
{
auto switches = Kakoune::complete(token.content.substr(1_byte), pos_in_token,
command.param_desc.switches |
transform(&SwitchMap::Item::key));
if (not switches.empty())
return Completions{start+1, cursor_pos, std::move(switches)};
return switches.empty() ? Completions{} : Completions{start+1, cursor_pos, std::move(switches)};
}
if (not command.completer)
return Completions{};