aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/window.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-16 08:37:42 +0800
committerGitHub <noreply@github.com>2023-02-16 08:37:42 +0800
commit5dc4eaf386d70b9bbef321a00bcbb5d475f36542 (patch)
tree4dd105e8c45b6f7b47f22afeb18b3bfcc8c0144f /src/nvim/window.c
parentf1c5887377c9ae547a7564ec4fc52d72656a974f (diff)
parent0bb3a373d32e150af3909e3873be91f34df211dc (diff)
downloadrneovim-5dc4eaf386d70b9bbef321a00bcbb5d475f36542.tar.gz
rneovim-5dc4eaf386d70b9bbef321a00bcbb5d475f36542.tar.bz2
rneovim-5dc4eaf386d70b9bbef321a00bcbb5d475f36542.zip
Merge pull request #22275 from zeertzjq/vim-9.0.1309
vim-patch:9.0.{1309,1310,1312}: scrolling two lines with even line count and 'scrolloff'
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r--src/nvim/window.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index c6694cd489..36d422abd5 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -4835,7 +4835,9 @@ static void win_enter_ext(win_T *const wp, const int flags)
if (*p_spk == 'c') {
changed_line_abv_curs(); // assume cursor position needs updating
} else {
- win_fix_cursor(true);
+ // Make sure the cursor position is valid, either by moving the cursor
+ // or by scrolling the text.
+ win_fix_cursor(get_real_state() & (MODE_NORMAL|MODE_CMDLINE|MODE_TERMINAL));
}
fix_current_dir();
@@ -6407,7 +6409,8 @@ void win_fix_scroll(int resize)
/// Make sure the cursor position is valid for 'splitkeep'.
/// If it is not, put the cursor position in the jumplist and move it.
-/// If we are not in normal mode, scroll to make valid instead.
+/// If we are not in normal mode ("normal" is zero), make it valid by scrolling
+/// instead.
static void win_fix_cursor(int normal)
{
win_T *wp = curwin;