diff --git a/src/highlighter_registry.cc b/src/highlighter_registry.cc index fdf8d15f..88f541c5 100644 --- a/src/highlighter_registry.cc +++ b/src/highlighter_registry.cc @@ -14,8 +14,8 @@ struct factory_not_found : public runtime_error void HighlighterRegistry::register_factory(const std::string& name, const HighlighterFactory& factory) { - assert(m_factories.find(name) == m_factories.end()); - m_factories[name] = factory; + assert(not m_factories.contains(name)); + m_factories.append(std::make_pair(name, factory)); } void HighlighterRegistry::add_highlighter_to_window(Window& window, @@ -32,14 +32,7 @@ void HighlighterRegistry::add_highlighter_to_window(Window& window, CandidateList HighlighterRegistry::complete_highlighter(const std::string& prefix, size_t cursor_pos) { - std::string real_prefix = prefix.substr(0, cursor_pos); - CandidateList result; - for (auto& highlighter : m_factories) - { - if (highlighter.first.substr(0, real_prefix.length()) == real_prefix) - result.push_back(highlighter.first); - } - return result; + return m_factories.complete_id(prefix, cursor_pos); } } diff --git a/src/highlighter_registry.hh b/src/highlighter_registry.hh index 19a285ea..4045cca4 100644 --- a/src/highlighter_registry.hh +++ b/src/highlighter_registry.hh @@ -7,6 +7,7 @@ #include "highlighter.hh" #include "utils.hh" #include "completion.hh" +#include "idvaluemap.hh" namespace Kakoune { @@ -32,7 +33,7 @@ public: size_t cursor_pos); private: - std::unordered_map m_factories; + idvaluemap m_factories; }; }