Append '/' to highlighter group completion candidates

This commit is contained in:
Maxime Coste 2017-11-02 18:05:18 +08:00
parent 20fe8e0112
commit 39e63cf518
3 changed files with 13 additions and 4 deletions

View File

@ -633,7 +633,7 @@ const CommandDesc rename_buffer_cmd = {
} }
}; };
static constexpr auto highlighter_scopes = { "global", "buffer", "window", "shared" }; static constexpr auto highlighter_scopes = { "global/", "buffer/", "window/", "shared/" };
template<bool add> template<bool add>
Completions highlighter_cmd_completer( Completions highlighter_cmd_completer(

View File

@ -62,9 +62,9 @@ Completions HighlighterGroup::complete_child(StringView path, ByteCount cursor_p
auto candidates = complete( auto candidates = complete(
path, cursor_pos, path, cursor_pos,
m_highlighters | filter([=](const HighlighterMap::Item& hl) m_highlighters | filter([=](auto& hl) { return not group or hl.value->has_children(); })
{ return not group or hl.value->has_children(); }) | transform([](auto& hl) { return hl.value->has_children() ? hl.key + "/" : hl.key; })
| transform(std::mem_fn(&HighlighterMap::Item::key))); | gather<Vector<String>>());
return { 0, 0, std::move(candidates) }; return { 0, 0, std::move(candidates) };
} }

View File

@ -328,6 +328,15 @@ Init accumulate(Range&& c, Init&& init, BinOp&& op)
return std::accumulate(begin(c), end(c), init, op); return std::accumulate(begin(c), end(c), init, op);
} }
template<typename Container>
auto gather()
{
return make_view_factory([](auto&& range) {
using std::begin; using std::end;
return Container(begin(range), end(range));
});
}
} }
#endif // ranges_hh_INCLUDED #endif // ranges_hh_INCLUDED