patch 9.1.1238: wrong cursor column with 'set splitkeep=screen'

Commit: 
https://github.com/vim/vim/commit/7746348c5d0f4c4707503f856d0335d8921e8d50
Author: phanium <91544758+pha...@users.noreply.github.com>
Date:   Tue Mar 25 20:15:31 2025 +0100

    patch 9.1.1238: wrong cursor column with 'set splitkeep=screen'
    
    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
short | vim - -u NONE --cmd 'set
    splitkeep=screen' +'norm $' +new +q
    ```
    
    fixes: #16968
    closes: #16971
    
    Signed-off-by: phanium <91544758+pha...@users.noreply.github.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim
index b6381a33b..c5edb0d4a 100644
--- a/src/testdir/test_window_cmd.vim
+++ b/src/testdir/test_window_cmd.vim
@@ -1979,6 +1979,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
diff --git a/src/version.c b/src/version.c
index ac7d719a5..2f4c3b311 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1238,
 /**/
     1237,
 /**/
diff --git a/src/window.c b/src/window.c
index 4fb7054e5..21f81e5fc 100644
--- a/src/window.c
+++ b/src/window.c
@@ -7038,7 +7038,7 @@ win_fix_scroll(int resize)
            {
                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.
@@ -7052,7 +7052,8 @@ win_fix_scroll(int resize)
                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;

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1tx9yO-00FIxG-UH%40256bit.org.

Raspunde prin e-mail lui