From 6e4b0d88599d43c59c2f035c2bdef97316469a9f Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 18 Jul 2022 21:35:38 +0200 Subject: [PATCH] Support "prompt -menu" to mark completions as authoritative This gives the "prompt" command the same "-menu" switch as "complete-command" and "define-command". I don't think anyone has asked for it but it seems like a good idea? --- src/commands.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/commands.cc b/src/commands.cc index 490c6309..c455803b 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -2158,6 +2158,7 @@ const CommandDesc prompt_cmd = { ParameterDesc{ { { "init", { true, "set initial prompt content" } }, { "password", { false, "Do not display entered text and clear reg after command" } }, + { "menu", { false, "treat completions as the only valid inputs" } }, { "file-completion", { false, "use file completion for prompt" } }, { "client-completion", { false, "use client completion for prompt" } }, { "buffer-completion", { false, "use buffer completion for prompt" } }, @@ -2177,7 +2178,9 @@ const CommandDesc prompt_cmd = { const String& command = parser[1]; auto initstr = parser.get_switch("init").value_or(StringView{}); - PromptCompleterAdapter completer = parse_completion_switch(parser, Completions::Flags::None); + const Completions::Flags completions_flags = parser.get_switch("menu") ? + Completions::Flags::Menu : Completions::Flags::None; + PromptCompleterAdapter completer = parse_completion_switch(parser, completions_flags); const auto flags = parser.get_switch("password") ? PromptFlags::Password : PromptFlags::None;