Mercurial > vim
diff src/normal.c @ 32535:72fd0421c183 v9.0.1599
patch 9.0.1599: Cursor not adjusted when 'splitkeep' is not "cursor"
Commit: https://github.com/vim/vim/commit/a109f39ef54bc3894768170f02c1b6ac56164488
Author: Luuk van Baal <luukvbaal@gmail.com>
Date: Fri Jun 2 14:16:35 2023 +0100
patch 9.0.1599: Cursor not adjusted when 'splitkeep' is not "cursor"
Problem: Cursor not adjusted when near top or bottom of window and
'splitkeep' is not "cursor".
Solution: Move boundary checks to outer cursor move functions, inner
functions should only return valid cursor positions. (Luuk van
Baal, closes #12480)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 02 Jun 2023 15:30:04 +0200 |
parents | 11bc7fa31c3b |
children | 448aef880252 |
line wrap: on
line diff
--- a/src/normal.c +++ b/src/normal.c @@ -2359,11 +2359,13 @@ nv_screengo(oparg_T *oap, int dir, long else { // to previous line - if (!cursor_up_inner(curwin, 1)) + if (curwin->w_cursor.lnum <= 1) { retval = FAIL; break; } + cursor_up_inner(curwin, 1); + linelen = linetabsize_str(ml_get_curline()); if (linelen > width1) curwin->w_curswant += (((linelen - width1 - 1) / width2) @@ -2386,12 +2388,15 @@ nv_screengo(oparg_T *oap, int dir, long else { // to next line - if (!cursor_down_inner(curwin, 1)) + if (curwin->w_cursor.lnum + >= curwin->w_buffer->b_ml.ml_line_count) { retval = FAIL; break; } + cursor_down_inner(curwin, 1); curwin->w_curswant %= width2; + // Check if the cursor has moved below the number display // when width1 < width2 (with cpoptions+=n). Subtract width2 // to get a negative value for w_curswant, which will get