Rework show_matching highlighter implementation
This commit is contained in:
parent
94bd32572d
commit
c2150dd163
|
@ -664,35 +664,37 @@ void show_matching_char(const Context& context, HighlightFlags flags, DisplayBuf
|
||||||
int level = 1;
|
int level = 1;
|
||||||
if (c == pair.first)
|
if (c == pair.first)
|
||||||
{
|
{
|
||||||
auto it = buffer.iterator_at(pos)+1;
|
for (auto it = buffer.iterator_at(pos)+1,
|
||||||
auto end = buffer.iterator_at(range.second);
|
end = buffer.iterator_at(range.second); it != end; ++it)
|
||||||
skip_while(it, end, [&](char c) {
|
{
|
||||||
|
char c = *it;
|
||||||
if (c == pair.first)
|
if (c == pair.first)
|
||||||
++level;
|
++level;
|
||||||
else if (c == pair.second and --level == 0)
|
else if (c == pair.second and --level == 0)
|
||||||
return false;
|
{
|
||||||
return true;
|
highlight_range(display_buffer, it.coord(), (it+1).coord(), false,
|
||||||
});
|
apply_face(face));
|
||||||
if (it != end)
|
break;
|
||||||
highlight_range(display_buffer, it.coord(), (it+1).coord(), false,
|
}
|
||||||
apply_face(face));
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else if (c == pair.second and pos > range.first)
|
else if (c == pair.second and pos > range.first)
|
||||||
{
|
{
|
||||||
auto it = buffer.iterator_at(pos)-1;
|
for (auto it = buffer.iterator_at(pos)-1,
|
||||||
auto end = buffer.iterator_at(range.first);
|
end = buffer.iterator_at(range.first); true; --it)
|
||||||
skip_while_reverse(it, end, [&](char c) {
|
{
|
||||||
|
char c = *it;
|
||||||
if (c == pair.second)
|
if (c == pair.second)
|
||||||
++level;
|
++level;
|
||||||
else if (c == pair.first and --level == 0)
|
else if (c == pair.first and --level == 0)
|
||||||
return false;
|
{
|
||||||
return true;
|
highlight_range(display_buffer, it.coord(), (it+1).coord(), false,
|
||||||
});
|
apply_face(face));
|
||||||
if (it != end or (*end == pair.first and level == 1))
|
break;
|
||||||
highlight_range(display_buffer, it.coord(), (it+1).coord(), false,
|
}
|
||||||
apply_face(face));
|
if (it == end)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user