HighlighterGroup: use idvaluemap::complete_id_if in complete_group_id
This commit is contained in:
parent
ce6b4c2cc4
commit
bb36271ae5
|
@ -44,4 +44,13 @@ CandidateList HighlighterGroup::complete_id(const std::string& prefix,
|
|||
return m_highlighters.complete_id<str_to_str>(prefix, cursor_pos);
|
||||
}
|
||||
|
||||
CandidateList HighlighterGroup::complete_group_id(const std::string& prefix,
|
||||
size_t cursor_pos)
|
||||
{
|
||||
return m_highlighters.complete_id_if<str_to_str>(
|
||||
prefix, cursor_pos,
|
||||
[](std::pair<std::string, HighlighterFunc>& func)
|
||||
{ return func.second.target<HighlighterGroup>() != nullptr; });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,18 +21,7 @@ public:
|
|||
HighlighterGroup& get_group(const std::string& id);
|
||||
|
||||
CandidateList complete_id(const std::string& prefix, size_t cursor_pos);
|
||||
|
||||
CandidateList complete_group_id(const std::string& prefix, size_t cursor_pos)
|
||||
{
|
||||
CandidateList all = complete_id(prefix, cursor_pos);
|
||||
CandidateList res;
|
||||
for (auto& id : all)
|
||||
{
|
||||
if (m_highlighters.find(id)->second.target<HighlighterGroup>())
|
||||
res.push_back(id);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
CandidateList complete_group_id(const std::string& prefix, size_t cursor_pos);
|
||||
|
||||
private:
|
||||
idvaluemap<std::string, HighlighterFunc> m_highlighters;
|
||||
|
|
Loading…
Reference in New Issue
Block a user