Do not complete command switches after --

Recently, switch completion were given the menu behavior.
Unfortunately this breaks cases like

	:echo -- -mark<ret>

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.
This commit is contained in:
Johannes Altmanninger 2022-07-31 07:38:46 +02:00
parent e83dbdcd2c
commit e13b435783

View File

@ -808,7 +808,8 @@ Completions CommandManager::complete(const Context& context,
const bool has_switches = not command.param_desc.switches.empty(); 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) == "-"; }; 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, auto switches = Kakoune::complete(token.content.substr(1_byte), pos_in_token,
concatenated(command.param_desc.switches concatenated(command.param_desc.switches