aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/window.c5
-rw-r--r--test/old/testdir/test_window_cmd.vim12
2 files changed, 15 insertions, 2 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 14b775db63..dd351a6af7 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -6431,7 +6431,7 @@ void win_fix_scroll(bool resize)
&& wp->w_botline - 1 <= wp->w_buffer->b_ml.ml_line_count) {
int diff = (wp->w_winrow - wp->w_prev_winrow)
+ (wp->w_height - wp->w_prev_height);
- linenr_T lnum = wp->w_cursor.lnum;
+ pos_T cursor = wp->w_cursor;
wp->w_cursor.lnum = wp->w_botline - 1;
// Add difference in height and row to botline.
@@ -6445,7 +6445,8 @@ void win_fix_scroll(bool resize)
// screen.
wp->w_fraction = FRACTION_MULT;
scroll_to_fraction(wp, wp->w_prev_height);
- wp->w_cursor.lnum = lnum;
+ wp->w_cursor = cursor;
+ wp->w_valid &= ~VALID_WCOL;
} else if (wp == curwin) {
wp->w_valid &= ~VALID_CROW;
}
diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim
index 24517f90cb..3501672f95 100644
--- a/test/old/testdir/test_window_cmd.vim
+++ b/test/old/testdir/test_window_cmd.vim
@@ -1934,6 +1934,18 @@ func Test_splitkeep_misc()
set splitkeep&
endfunc
+func Test_splitkeep_screen_cursor_pos()
+ new
+ set splitkeep=screen
+ call setline(1, ["longer than the last", "shorter"])
+ norm! $
+ wincmd s
+ close
+ call assert_equal([0, 1, 20, 0], getpos('.'))
+ %bwipeout!
+ set splitkeep&
+endfunc
+
func Test_splitkeep_cursor()
CheckScreendump
let lines =<< trim END