summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-02-01 23:19:07 +0000
committerMaxime Coste <frrrwww@gmail.com>2015-02-01 23:19:07 +0000
commit4d6b8a70e1ea140871455d31172b4e35c3caaa99 (patch)
treef32eef18f0bba9b0288dcc707c169b05f0cd6218
parentd3bccfeb941fb5e8a26034b5599edd8f5814ab47 (diff)
Fix highlighter update with new LineModification behaviour
-rw-r--r--src/highlighters.cc15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc
index 20f09181..0a3733c6 100644
--- a/src/highlighters.cc
+++ b/src/highlighters.cc
@@ -741,18 +741,17 @@ void update_matches(const Buffer& buffer, ArrayView<LineModification> modifs,
auto ins_pos = matches.begin();
for (auto it = ins_pos; it != matches.end(); ++it)
{
- auto modif_it = std::lower_bound(modifs.begin(), modifs.end(), it->line,
- [](const LineModification& c, const LineCount& l)
- { return c.old_line < l; });
+ auto modif_it = std::upper_bound(modifs.begin(), modifs.end(), it->line,
+ [](const LineCount& l, const LineModification& c)
+ { return l < c.old_line; });
- bool erase = (modif_it != modifs.end() and modif_it->old_line == it->line);
- if (not erase and modif_it != modifs.begin())
+ bool erase = false;
+ if (modif_it != modifs.begin())
{
auto& prev = *(modif_it-1);
erase = it->line < prev.old_line + prev.num_removed;
it->line += prev.diff();
}
- erase = erase or (it->line >= buffer.line_count());
if (not erase)
{
@@ -773,9 +772,7 @@ void update_matches(const Buffer& buffer, ArrayView<LineModification> modifs,
// try to find new matches in each updated lines
for (auto& modif : modifs)
{
- for (auto line = modif.new_line;
- line < modif.new_line + modif.num_added and
- line < buffer.line_count(); ++line)
+ for (auto line = modif.new_line; line < modif.new_line + modif.num_added; ++line)
{
auto l = buffer[line];
for (RegexIterator<const char*> it{l.begin(), l.end(), regex}, end{}; it != end; ++it)