From e13b43578369652ef5acb0e2295d889bc7191018 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 31 Jul 2022 07:38:46 +0200 Subject: [PATCH] Do not complete command switches after -- Recently, switch completion were given the menu behavior. Unfortunately this breaks cases like :echo -- -mark where the hypothetical user wanted to actually display "-mark", not "-markup". Simply bail if there is a double-dash. This is not fully correct, for example it wrongly disables switch completion on echo -to-file -- - but that's minor, we can fix it later. In future, we should reuse the ParametersParser when computing completions, which will obsolete this workaround. --- src/command_manager.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/command_manager.cc b/src/command_manager.cc index 48d7789e..5e2253bd 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -808,7 +808,8 @@ Completions CommandManager::complete(const Context& context, 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)) + if (is_switch(token.content) + and not contains(tokens | drop(1) | transform(&Token::content), "--")) { auto switches = Kakoune::complete(token.content.substr(1_byte), pos_in_token, concatenated(command.param_desc.switches