regionref highlighter just ignore invalid references

fixes #68
This commit is contained in:
Maxime Coste 2014-02-25 00:18:16 +00:00
parent daeefe2f33
commit 6d651c59d0
2 changed files with 13 additions and 4 deletions

View File

@ -8,6 +8,11 @@
namespace Kakoune
{
struct group_not_found : public runtime_error
{
using runtime_error::runtime_error;
};
template<typename... Args>
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<FunctionGroup>();
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

View File

@ -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 + ")",