diff --git a/src/function_group.hh b/src/function_group.hh index 5a58bf68..a3371c53 100644 --- a/src/function_group.hh +++ b/src/function_group.hh @@ -8,6 +8,11 @@ namespace Kakoune { +struct group_not_found : public runtime_error +{ + using runtime_error::runtime_error; +}; + template class FunctionGroup { @@ -39,10 +44,10 @@ public: String id(path.begin(), sep_it); auto it = m_functions.find(id); if (it == m_functions.end()) - throw runtime_error("no such id: " + id); + throw group_not_found("no such id: " + id); FunctionGroup* group = it->second.template target(); if (not group) - throw runtime_error("not a group: " + id); + throw group_not_found("not a group: " + id); if (sep_it != path.end()) return group->get_group(String(sep_it+1, path.end()), path_separator); else diff --git a/src/highlighters.cc b/src/highlighters.cc index c8a33a6b..f8ec99c0 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -807,8 +807,12 @@ HighlighterAndId region_ref_factory(HighlighterParameters params) auto func = [name](const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferCoord begin, BufferCoord end) { - HighlighterGroup& ref = DefinedHighlighters::instance().get_group(name, '/'); - apply_highlighter(context, flags, display_buffer, begin, end, ref); + try + { + HighlighterGroup& ref = DefinedHighlighters::instance().get_group(name, '/'); + apply_highlighter(context, flags, display_buffer, begin, end, ref); + } + catch (group_not_found&) {} }; return HighlighterAndId("regionref(" + params[0] + "," + params[1] + "," + name + ")",