aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/normal.c
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2023-06-02 17:26:41 +0200
committerGitHub <noreply@github.com>2023-06-02 23:26:41 +0800
commitc45a111e35478d2173d8ed5bab2eb73ab2de590c (patch)
treec3227d91efb331e903c15f09cdd8f63725d3d0e3 /src/nvim/normal.c
parentaa130d0c7ea69a05330d0b054b414cc3a15dac45 (diff)
downloadrneovim-c45a111e35478d2173d8ed5bab2eb73ab2de590c.tar.gz
rneovim-c45a111e35478d2173d8ed5bab2eb73ab2de590c.tar.bz2
rneovim-c45a111e35478d2173d8ed5bab2eb73ab2de590c.zip
vim-patch:9.0.1599: Cursor not adjusted when 'splitkeep' is not "cursor" (#23884)
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 vim/vim#12480) https://github.com/vim/vim/commit/a109f39ef54bc3894768170f02c1b6ac56164488
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r--src/nvim/normal.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 60fff45323..f3909030c9 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -2493,10 +2493,12 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
curwin->w_curswant -= width2;
} else {
// to previous line
- if (!cursor_up_inner(curwin, 1)) {
+ if (curwin->w_cursor.lnum <= 1) {
retval = false;
break;
}
+ cursor_up_inner(curwin, 1);
+
linelen = linetabsize_str(get_cursor_line_ptr());
if (linelen > width1) {
int w = (((linelen - width1 - 1) / width2) + 1) * width2;
@@ -2516,11 +2518,13 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
curwin->w_curswant += width2;
} else {
// to next line
- if (!cursor_down_inner(curwin, 1)) {
+ if (curwin->w_cursor.lnum >= curwin->w_buffer->b_ml.ml_line_count) {
retval = false;
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