summaryrefslogtreecommitdiff
path: root/src/input_handler.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2016-12-10 13:33:42 +0000
committerMaxime Coste <mawww@kakoune.org>2016-12-10 13:33:42 +0000
commit5d9f3b7f3f38fd7153edda2992e77114d6e1dd83 (patch)
tree6f190346ca11b3db40ed25401d7ed6cfd90af356 /src/input_handler.cc
parent0f486666e02b46e3f506629b64cc481d9f4063ef (diff)
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
Diffstat (limited to 'src/input_handler.cc')
-rw-r--r--src/input_handler.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index fae254fb..7d3ce050 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -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)),