Ensure the line is correctly clamped in scroll_window
Seems like the previous implementation was not always doing that correctly, so just use an obviously correct method. Fixes #951
This commit is contained in:
parent
0f486666e0
commit
5d9f3b7f3f
|
@ -1515,9 +1515,11 @@ void scroll_window(Context& context, LineCount offset)
|
|||
SelectionList& selections = context.selections();
|
||||
const BufferCoord cursor = selections.main().cursor();
|
||||
|
||||
auto line = clamp(cursor.line, win_pos.line + scrolloff.line,
|
||||
win_pos.line + win_dim.line - 1 - scrolloff.line);
|
||||
line = clamp(line, 0_line, line_count-1);
|
||||
|
||||
using std::min; using std::max;
|
||||
auto line = clamp(cursor.line, max(0_line, win_pos.line + scrolloff.line),
|
||||
min(line_count-1, win_pos.line + win_dim.line - 1 - scrolloff.line));
|
||||
// This is not exactly a clamp, and must be done in this order as
|
||||
// byte_count_to could return line length
|
||||
auto col = min(max(cursor.column, buffer[line].byte_count_to(win_pos.column)),
|
||||
|
|
Loading…
Reference in New Issue
Block a user