diff options
| author | Maxime Coste <mawww@kakoune.org> | 2024-03-22 21:00:38 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-03-22 21:03:58 +1100 |
| commit | a1e6799aa9a4b2509a6a3af7c4bf4889bb826e2e (patch) | |
| tree | 36b87936cd70af064d4f2a933391de1a3034911c /src/display_buffer.hh | |
| parent | 7e75c9a1dfb1e7829fe72599e69ab64356c102c4 (diff) | |
Fix DisplayLines not tracking their buffer range correctly
After extracting the whole buffer content, a line can end up with
only non-range highlgihters pending which makes its range become
0.0,0.0, after running highlighting on the extracted range it gets
re-inserted but taking the min of existing range and inserted range
wrongly returns 0.0. Avoid this by detecting that the 0.0,0.0 range
does not actually mean anything when we have no ranged atoms.
Fixes #5001
Diffstat (limited to 'src/display_buffer.hh')
| -rw-r--r-- | src/display_buffer.hh | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/display_buffer.hh b/src/display_buffer.hh index c13bd0b9..c4ea6fb5 100644 --- a/src/display_buffer.hh +++ b/src/display_buffer.hh @@ -138,11 +138,12 @@ public: iterator insert(iterator pos, It beg, It end) { auto has_buffer_range = std::mem_fn(&DisplayAtom::has_buffer_range); + auto had_range = any_of(*this, has_buffer_range); if (auto first = std::find_if(beg, end, has_buffer_range); first != end) { auto& last = *std::find_if(std::reverse_iterator(end), std::reverse_iterator(first), has_buffer_range); - m_range.begin = std::min(m_range.begin, (*first).begin()); - m_range.end = std::max(m_range.end, last.end()); + m_range.begin = had_range ? std::min(m_range.begin, (*first).begin()) : (*first).begin(); + m_range.end = had_range ? std::max(m_range.end, last.end()) : last.end(); } return m_atoms.insert(pos, beg, end); } |
