Use menu behavior for add-highlighter/remove-highlighter completion

This means that typing

	:add-highlighter g c 80

results in

	:add-highlighter global/ column 80

Paths for add-highlighter do not get the menu behavior because we
want to be able to type "global/foo" even if "global/foobar" exists.
main
Johannes Altmanninger 2022-07-19 10:30:01 +02:00
parent 8fac31ba76
commit 7f08ac3de2
3 changed files with 8 additions and 4 deletions

View File

@ -883,7 +883,8 @@ Completions highlighter_cmd_completer(
StringView path = params[0];
auto sep_it = find(path, '/');
if (sep_it == path.end())
return { 0_byte, pos_in_token, complete(path, pos_in_token, highlighter_scopes) };
return { 0_byte, pos_in_token, complete(path, pos_in_token, highlighter_scopes),
Completions::Flags::Menu };
StringView scope{path.begin(), sep_it};
HighlighterGroup* root = nullptr;
@ -900,7 +901,8 @@ Completions highlighter_cmd_completer(
else if (add and token_to_complete == 1)
{
StringView name = params[1];
return { 0_byte, name.length(), complete(name, pos_in_token, HighlighterRegistry::instance() | transform(&HighlighterRegistry::Item::key)) };
return { 0_byte, name.length(), complete(name, pos_in_token, HighlighterRegistry::instance() | transform(&HighlighterRegistry::Item::key)),
Completions::Flags::Menu };
}
else
return {};

View File

@ -75,7 +75,8 @@ Completions HighlighterGroup::complete_child(StringView path, ByteCount cursor_p
| transform([](auto& hl) { return hl.value->has_children() ? hl.key + "/" : hl.key; })
| gather<Vector<String>>());
return { 0, 0, std::move(candidates) };
auto completions_flags = group ? Completions::Flags::None : Completions::Flags::Menu;
return { 0, 0, std::move(candidates), completions_flags };
}
void Highlighters::highlight(HighlightContext context, DisplayBuffer& display_buffer, BufferRange range)

View File

@ -2089,7 +2089,8 @@ public:
}
auto container = m_regions | transform(&decltype(m_regions)::Item::key);
return { 0, 0, complete(path, cursor_pos, container) };
auto completions_flags = group ? Completions::Flags::None : Completions::Flags::Menu;
return { 0, 0, complete(path, cursor_pos, container), completions_flags };
}
static std::unique_ptr<Highlighter> create(HighlighterParameters params, Highlighter*)