summaryrefslogtreecommitdiff
path: root/src/command_manager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/command_manager.cc')
-rw-r--r--src/command_manager.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc
index 91b5fb82..7537f450 100644
--- a/src/command_manager.cc
+++ b/src/command_manager.cc
@@ -663,9 +663,19 @@ Completions CommandManager::complete(const Context& context,
}
auto command_it = find_command(context, command_name);
- if (command_it == m_commands.end() or
- not command_it->value.completer)
- return Completions();
+ if (command_it == m_commands.end())
+ return Completions{};
+
+ if (token.content.substr(0_byte, 1_byte) == "-")
+ {
+ auto switches = Kakoune::complete(token.content.substr(1_byte), cursor_pos_in_token,
+ command_it->value.param_desc.switches |
+ transform(&SwitchMap::Item::key));
+ if (not switches.empty())
+ return Completions{start+1, cursor_pos, std::move(switches)};
+ }
+ if (not command_it->value.completer)
+ return Completions{};
Vector<String> params;
for (auto it = tokens.begin() + 1; it != tokens.end(); ++it)