vim-patch:9.1.0357: Page scrolling should place cursor at window boundaries (#28429)

Problem:  Page scrolling does not always place the cursor at the top or
          bottom of the window (Mathias Rav)
Solution: Place the cursor at the top or bottom of the window.
          (Luuk van Baal)

4b6b0c4024
This commit is contained in:
luukvbaal
2024-04-22 15:24:32 +02:00
committed by GitHub
parent 783b0aba41
commit ea1c9f60e0
3 changed files with 33 additions and 16 deletions

View File

@@ -2492,23 +2492,27 @@ int pagescroll(Direction dir, int count, bool half)
} else {
cursor_up_inner(curwin, curscount);
}
if (get_scrolloff_value(curwin) > 0) {
cursor_correct(curwin);
}
// Move cursor to first line of closed fold.
foldAdjustCursor(curwin);
nochange = nochange
&& prev_col == curwin->w_cursor.col
&& prev_lnum == curwin->w_cursor.lnum;
} else {
// Scroll [count] times 'window' or current window height lines.
count *= ((ONE_WINDOW && p_window > 0 && p_window < Rows - 1)
? MAX(1, (int)p_window - 2) : get_scroll_overlap(dir));
nochange = scroll_with_sms(dir, count);
// Place cursor at top or bottom of window.
validate_botline(curwin);
curwin->w_cursor.lnum = (dir == FORWARD ? curwin->w_topline : curwin->w_botline - 1);
}
if (get_scrolloff_value(curwin) > 0) {
cursor_correct(curwin);
}
// Move cursor to first line of closed fold.
foldAdjustCursor(curwin);
nochange = nochange
&& prev_col == curwin->w_cursor.col
&& prev_lnum == curwin->w_cursor.lnum;
// Error if both the viewport and cursor did not change.
if (nochange) {
beep_flush();