From 09fc14be4b7169e3d5fbae3995c3ee9c6db03150 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 1 Feb 2015 23:30:58 +0000 Subject: [PATCH] Small refactor in highlighters.cc --- src/highlighters.cc | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/highlighters.cc b/src/highlighters.cc index 0a3733c6..627bc20b 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -745,26 +745,24 @@ void update_matches(const Buffer& buffer, ArrayView modifs, [](const LineCount& l, const LineModification& c) { return l < c.old_line; }); - bool erase = false; if (modif_it != modifs.begin()) { auto& prev = *(modif_it-1); - erase = it->line < prev.old_line + prev.num_removed; + if (it->line < prev.old_line + prev.num_removed) + continue; // match removed + it->line += prev.diff(); } - if (not erase) - { - it->timestamp = buf_timestamp; - kak_assert(buffer.is_valid(it->begin_coord()) or - buffer[it->line].length() == it->begin); - kak_assert(buffer.is_valid(it->end_coord()) or - buffer[it->line].length() == it->end); + it->timestamp = buf_timestamp; + kak_assert(buffer.is_valid(it->begin_coord()) or + buffer[it->line].length() == it->begin); + kak_assert(buffer.is_valid(it->end_coord()) or + buffer[it->line].length() == it->end); - if (ins_pos != it) - *ins_pos = std::move(*it); - ++ins_pos; - } + if (ins_pos != it) + *ins_pos = std::move(*it); + ++ins_pos; } matches.erase(ins_pos, matches.end()); size_t pivot = matches.size();