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.
This commit is contained in:
Johannes Altmanninger 2022-07-19 09:42:20 +02:00
parent ba557e90a2
commit 8fac31ba76

View File

@ -769,7 +769,9 @@ Completions CommandManager::complete(const Context& context,
concatenated(command.param_desc.switches concatenated(command.param_desc.switches
| transform(&SwitchMap::Item::key), | transform(&SwitchMap::Item::key),
ConstArrayView<String>{"-"})); ConstArrayView<String>{"-"}));
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) if (not command.completer)
return Completions{}; return Completions{};