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.
This commit is contained in:
parent
ce75867e44
commit
50cacc0758
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user