From a3b4743b4341d857ffc8a103f25ccb42ebc0e292 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 26 Mar 2025 06:58:36 +0800 Subject: vim-patch:9.1.1238: wrong cursor column with 'set splitkeep=screen' (#33060) Problem: With ':set splitkeep=screen', cursor did't restore column correctly when splitting a window on a line longer than the last line on the screen (after v9.1.0707) Solution: Restore cursor column in `win_fix_scroll()` since it may be changed in `getvcol()` after 396fd1ec2956 (phanium). Example: ``` echo longlonglongling\nshort | vim - -u NONE --cmd 'set splitkeep=screen' +'norm $' +new +q ``` fixes: vim/vim#16968 closes: vim/vim#16971 https://github.com/vim/vim/commit/7746348c5d0f4c4707503f856d0335d8921e8d50 Co-authored-by: phanium <91544758+phanen@users.noreply.github.com> --- src/nvim/window.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim') 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; } -- cgit