summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-03-27 13:18:06 +0000
committerMaxime Coste <frrrwww@gmail.com>2015-03-27 13:18:06 +0000
commitc2150dd1630f5aed73ee46f40bf8b20cc3710636 (patch)
tree6ce787ac23c0f4c3fbe59d4ef4bffd750a41b3bf /src
parent94bd32572dc675275b995c3b675784183bda1176 (diff)
Rework show_matching highlighter implementation
Diffstat (limited to 'src')
-rw-r--r--src/highlighters.cc42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc
index 63632528..357ab120 100644
--- a/src/highlighters.cc
+++ b/src/highlighters.cc
@@ -664,35 +664,37 @@ void show_matching_char(const Context& context, HighlightFlags flags, DisplayBuf
int level = 1;
if (c == pair.first)
{
- auto it = buffer.iterator_at(pos)+1;
- auto end = buffer.iterator_at(range.second);
- skip_while(it, end, [&](char c) {
+ for (auto it = buffer.iterator_at(pos)+1,
+ end = buffer.iterator_at(range.second); it != end; ++it)
+ {
+ char c = *it;
if (c == pair.first)
++level;
else if (c == pair.second and --level == 0)
- return false;
- return true;
- });
- if (it != end)
- highlight_range(display_buffer, it.coord(), (it+1).coord(), false,
- apply_face(face));
- break;
+ {
+ highlight_range(display_buffer, it.coord(), (it+1).coord(), false,
+ apply_face(face));
+ break;
+ }
+ }
}
else if (c == pair.second and pos > range.first)
{
- auto it = buffer.iterator_at(pos)-1;
- auto end = buffer.iterator_at(range.first);
- skip_while_reverse(it, end, [&](char c) {
+ for (auto it = buffer.iterator_at(pos)-1,
+ end = buffer.iterator_at(range.first); true; --it)
+ {
+ char c = *it;
if (c == pair.second)
++level;
else if (c == pair.first and --level == 0)
- return false;
- return true;
- });
- if (it != end or (*end == pair.first and level == 1))
- highlight_range(display_buffer, it.coord(), (it+1).coord(), false,
- apply_face(face));
- break;
+ {
+ highlight_range(display_buffer, it.coord(), (it+1).coord(), false,
+ apply_face(face));
+ break;
+ }
+ if (it == end)
+ break;
+ }
}
}
}