Skip to content

Commit

Permalink
Fix switch completion
Browse files Browse the repository at this point in the history
  • Loading branch information
mawww committed May 30, 2022
1 parent d9ea626 commit ac6f928
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/command_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand Down

0 comments on commit ac6f928

Please sign in to comment.