From 09cd7207c04cc609e31c75f4e4ad83f0d2f7566b Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 22 Jul 2022 11:28:47 +0200 Subject: [PATCH] Use menu behavior when completing %opt/%val expansions Now that the completions include closing delimiters, this is actually useful because we can type echo %val{bufn and it will do the right thing. Don't include register expansions because we currently don't offer completions for all registers. (We could add that fairly easily. We'd want to handle some interesting edge cases. For example query %reg| should be completed to %reg|:| but also %reg||||.) File expansions of files that contain a quoting delimiter will be wrong but that's an unrelated problem, and also pretty minor since %file{} is rarely used interactively. --- src/command_manager.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/command_manager.cc b/src/command_manager.cc index 522d1e46a..643fbc73c 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -705,7 +705,9 @@ static Completions complete_expansion(const Context& context, CompletionFlags fl c += to_string(token.terminator->character); } - return { start, cursor_pos, candidates }; + auto completions_flags = token.type == Token::Type::RegisterExpand + ? Completions::Flags::None : Completions::Flags::Menu; + return { start, cursor_pos, candidates, completions_flags }; } static Completions complete_expand(const Context& context, CompletionFlags flags,