mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-15 09:17:22 +03:00
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
This commit is contained in:
parent
832e9155fa
commit
2cd0ce41ac
@ -359,9 +359,7 @@ private:
|
|||||||
// Thanks to the ensure_first_face_is_capture_0 method, we know
|
// Thanks to the ensure_first_face_is_capture_0 method, we know
|
||||||
// these point to the first/last matches capture 0.
|
// these point to the first/last matches capture 0.
|
||||||
auto first_end = matches.begin()->end;
|
auto first_end = matches.begin()->end;
|
||||||
auto last_begin = (matches.end() - m_faces.size())->begin;
|
auto last_end = (matches.end() - m_faces.size())->end;
|
||||||
|
|
||||||
bool remove_last = true;
|
|
||||||
|
|
||||||
// add regex matches from new begin to old first match end
|
// add regex matches from new begin to old first match end
|
||||||
if (range.begin < old_range.begin)
|
if (range.begin < old_range.begin)
|
||||||
@ -371,11 +369,6 @@ private:
|
|||||||
add_matches(buffer, new_matches, {range.begin, first_end});
|
add_matches(buffer, new_matches, {range.begin, first_end});
|
||||||
matches.erase(matches.begin(), matches.begin() + m_faces.size());
|
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::copy(std::make_move_iterator(new_matches.begin()),
|
||||||
std::make_move_iterator(new_matches.end()),
|
std::make_move_iterator(new_matches.end()),
|
||||||
std::inserter(matches, matches.begin()));
|
std::inserter(matches, matches.begin()));
|
||||||
@ -384,9 +377,7 @@ private:
|
|||||||
if (old_range.end < range.end)
|
if (old_range.end < range.end)
|
||||||
{
|
{
|
||||||
old_range.end = range.end;
|
old_range.end = range.end;
|
||||||
if (remove_last)
|
add_matches(buffer, matches, {last_end, range.end});
|
||||||
matches.erase(matches.end() - m_faces.size(), matches.end());
|
|
||||||
add_matches(buffer, matches, {last_begin, range.end});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return it->matches;
|
return it->matches;
|
||||||
|
Loading…
Reference in New Issue
Block a user