diff options
| author | Maxime Coste <mawww@kakoune.org> | 2022-07-11 18:17:51 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2022-07-11 18:17:51 +1000 |
| commit | 50cacc0758ea7e6acd7dcc350f8dbb2e6559a30e (patch) | |
| tree | b30d5fbdff8b598cbe38d7719b8f5ad12015a6b6 /src | |
| parent | ce75867e441a1ebde0e3d9e434672a05b49bd9e3 (diff) | |
Fix buffer location of column highlighter's past-eol atoms
Using buffer end was confusing Window::display_position that
assumes display atom buffer locations are always increasing.
Diffstat (limited to 'src')
| -rw-r--r-- | src/display_buffer.cc | 3 | ||||
| -rw-r--r-- | src/display_buffer.hh | 2 | ||||
| -rw-r--r-- | src/highlighters.cc | 8 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/display_buffer.cc b/src/display_buffer.cc index a1dfbc36..2b377310 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -134,7 +134,7 @@ DisplayLine::iterator DisplayLine::insert(iterator it, DisplayAtom atom) return res; } -void DisplayLine::push_back(DisplayAtom atom) +DisplayAtom& DisplayLine::push_back(DisplayAtom atom) { if (atom.has_buffer_range()) { @@ -142,6 +142,7 @@ void DisplayLine::push_back(DisplayAtom atom) m_range.end = std::max(m_range.end, atom.end()); } m_atoms.push_back(std::move(atom)); + return m_atoms.back(); } DisplayLine::iterator DisplayLine::erase(iterator beg, iterator end) diff --git a/src/display_buffer.hh b/src/display_buffer.hh index ec5da89e..6d739095 100644 --- a/src/display_buffer.hh +++ b/src/display_buffer.hh @@ -142,7 +142,7 @@ public: } iterator erase(iterator beg, iterator end); - void push_back(DisplayAtom atom); + DisplayAtom& push_back(DisplayAtom atom); // remove first_col from the begining of the line, and make sure // the line is less that col_count character diff --git a/src/highlighters.cc b/src/highlighters.cc index 3f60721e..6d370aae 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -647,8 +647,12 @@ std::unique_ptr<Highlighter> create_column_highlighter(HighlighterParameters par auto remaining_col = column; bool found = false; auto first_buf = find_if(line, [](auto& atom) { return atom.has_buffer_range(); }); + BufferCoord last_pos{}; for (auto atom_it = first_buf; atom_it != line.end(); ++atom_it) { + if (atom_it->has_buffer_range()) + last_pos = atom_it->end(); + const auto atom_len = atom_it->length(); if (remaining_col < atom_len) { @@ -666,8 +670,8 @@ std::unique_ptr<Highlighter> create_column_highlighter(HighlighterParameters par continue; if (remaining_col > 0) - line.push_back({buffer, buffer.end_coord(), buffer.end_coord(), String{' ', remaining_col}}); - line.push_back({" ", face}); + line.push_back({buffer, last_pos, last_pos, String{' ', remaining_col}}); + line.push_back({buffer, last_pos, last_pos, " "}).face = face; } }; |
