summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-10-18 11:37:04 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-10-18 11:37:04 +0100
commit2cd0ce41ac8678a766b8838d37bc0a54a9935b95 (patch)
tree28aa324448358a4db3d8eb5a55a339deb5eaa971 /src
parent832e9155fa95b7f98d3ce42e64b888588c1de8aa (diff)
Do not try to extend last match when updating regex matches
It does not work well with regexes starting with a lookbehind, as we would need to reparse from further away, leading to the last match just being removed. It seems safer not to remove it, as the motivating use case (multiline macros) is better left to regions anyway. Fixes #440
Diffstat (limited to 'src')
-rw-r--r--src/highlighters.cc13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc
index 3bbccca8..648e6072 100644
--- a/src/highlighters.cc
+++ b/src/highlighters.cc
@@ -359,9 +359,7 @@ private:
// Thanks to the ensure_first_face_is_capture_0 method, we know
// these point to the first/last matches capture 0.
auto first_end = matches.begin()->end;
- auto last_begin = (matches.end() - m_faces.size())->begin;
-
- bool remove_last = true;
+ auto last_end = (matches.end() - m_faces.size())->end;
// add regex matches from new begin to old first match end
if (range.begin < old_range.begin)
@@ -371,11 +369,6 @@ private:
add_matches(buffer, new_matches, {range.begin, first_end});
matches.erase(matches.begin(), matches.begin() + m_faces.size());
- // first matches was last matches as well, so
- // make sure we do not try to remove them again.
- if (matches.empty())
- remove_last = false;
-
std::copy(std::make_move_iterator(new_matches.begin()),
std::make_move_iterator(new_matches.end()),
std::inserter(matches, matches.begin()));
@@ -384,9 +377,7 @@ private:
if (old_range.end < range.end)
{
old_range.end = range.end;
- if (remove_last)
- matches.erase(matches.end() - m_faces.size(), matches.end());
- add_matches(buffer, matches, {last_begin, range.end});
+ add_matches(buffer, matches, {last_end, range.end});
}
}
return it->matches;