From ba557e90a26e75c9222859b63237a60e94d8d794 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 19 Jul 2022 10:04:32 +0200 Subject: Offer "--" as completion when completing switches The next commit will give switch completions the menu behavior, so this is necessary so we can still type "echo --" without an auto-expansion to "echo -to-file". --- src/command_manager.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/command_manager.cc') diff --git a/src/command_manager.cc b/src/command_manager.cc index 30684d85..e014d1d3 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -766,8 +766,9 @@ Completions CommandManager::complete(const Context& context, 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)); + concatenated(command.param_desc.switches + | transform(&SwitchMap::Item::key), + ConstArrayView{"-"})); return switches.empty() ? Completions{} : Completions{start+1, cursor_pos, std::move(switches)}; } if (not command.completer) -- cgit v1.2.3 From 8fac31ba76e6036229baa751c41c21695f07372d Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 19 Jul 2022 09:42:20 +0200 Subject: Use menu behavior for completion of switches We already use the menu behavior in complete_command_name(); let's do the same for switches, since we can complete all valid inputs and it can save a Tab key in some scenarios. CommandManager::complete is fairly complex. We can't expect callers to add the menu bit when appropriate, so we currently do it here. --- src/command_manager.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/command_manager.cc') diff --git a/src/command_manager.cc b/src/command_manager.cc index e014d1d3..1fb82731 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -769,7 +769,9 @@ Completions CommandManager::complete(const Context& context, concatenated(command.param_desc.switches | transform(&SwitchMap::Item::key), ConstArrayView{"-"})); - return switches.empty() ? Completions{} : Completions{start+1, cursor_pos, std::move(switches)}; + return switches.empty() + ? Completions{} + : Completions{start+1, cursor_pos, std::move(switches), Completions::Flags::Menu}; } if (not command.completer) return Completions{}; -- cgit v1.2.3