Support highlighters that add new lines in scroll_to_keep_cursor_visible
This commit is contained in:
parent
3021c7f60a
commit
61cc53b325
|
@ -112,10 +112,13 @@ static LineCount adapt_view_pos(LineCount line, LineCount offset,
|
|||
return view_pos;
|
||||
}
|
||||
|
||||
static CharCount adapt_view_pos(const DisplayLine& line, BufferCoord pos, CharCount view_pos, CharCount view_size)
|
||||
static CharCount adapt_view_pos(const DisplayBuffer& display_buffer,
|
||||
BufferCoord pos, CharCount view_pos, CharCount view_size)
|
||||
{
|
||||
CharCount buffer_column = 0;
|
||||
CharCount non_buffer_column = 0;
|
||||
for (auto& line : display_buffer.lines())
|
||||
{
|
||||
for (auto& atom : line)
|
||||
{
|
||||
if (atom.has_buffer_range())
|
||||
|
@ -134,6 +137,7 @@ static CharCount adapt_view_pos(const DisplayLine& line, BufferCoord pos, CharCo
|
|||
else
|
||||
non_buffer_column += atom.length();
|
||||
}
|
||||
}
|
||||
return view_pos;
|
||||
}
|
||||
|
||||
|
@ -164,10 +168,10 @@ void Window::scroll_to_keep_cursor_visible_ifn()
|
|||
// (this is only valid if highlighting one line and multiple lines put
|
||||
// the cursor in the same position, however I do not find any sane example
|
||||
// of highlighters not doing that)
|
||||
m_position.column = adapt_view_pos(lines.back(),
|
||||
m_position.column = adapt_view_pos(display_buffer,
|
||||
first.line == last.line ? first : last.line,
|
||||
m_position.column, m_dimensions.column);
|
||||
m_position.column = adapt_view_pos(lines.back(), last,
|
||||
m_position.column = adapt_view_pos(display_buffer, last,
|
||||
m_position.column, m_dimensions.column);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user