0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

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)
This commit is contained in:
Luuk van Baal
2023-06-02 14:16:35 +01:00
committed by Bram Moolenaar
parent 47eec6716b
commit a109f39ef5
6 changed files with 77 additions and 59 deletions

View File

@@ -2359,11 +2359,13 @@ nv_screengo(oparg_T *oap, int dir, long dist)
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 dist)
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