Fix highlighter update with new LineModification behaviour

This commit is contained in:
Maxime Coste 2015-02-01 23:19:07 +00:00
parent d3bccfeb94
commit 4d6b8a70e1

View File

@ -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)