summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2022-05-30 19:27:18 +1000
committerMaxime Coste <mawww@kakoune.org>2022-05-30 19:27:18 +1000
commitac6f928ad4f47360eb90f2b0b8d098c6e70cce1b (patch)
tree280f552f45e47e7b218507fcd9a587c0c6c7225e /src
parentd9ea62666b2671bc1ee4ef2dd7debd6fe8965dcf (diff)
Fix switch completion
Diffstat (limited to 'src')
-rw-r--r--src/command_manager.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc
index c051a4bf..30684d85 100644
--- a/src/command_manager.cc
+++ b/src/command_manager.cc
@@ -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{};