patch 9.0.2081: smoothscroll may result in wrong cursor position

Commit: 
https://github.com/vim/vim/commit/1bf1bf569b96d2f9b28e0cce0968ffbf2fb80aac
Author: Luuk van Baal <[email protected]>
Date:   Sat Oct 28 21:43:31 2023 +0200

    patch 9.0.2081: smoothscroll may result in wrong cursor position
    
    Problem:  With 'smoothscroll' set, "w_skipcol" is not reset when unsetting 
'wrap'.
              Resulting in incorrect calculation of the cursor position.
    Solution: Reset "w_skipcol" when unsetting 'wrap'.
    
    fixes:  #12970
    closes: #13439
    
    Signed-off-by: Luuk van Baal <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/option.c b/src/option.c
index 180aca221..35529a576 100644
--- a/src/option.c
+++ b/src/option.c
@@ -4081,11 +4081,9 @@ did_set_showtabline(optset_T *args UNUSED)
     char *
 did_set_smoothscroll(optset_T *args UNUSED)
 {
-    if (curwin->w_p_sms)
-       return NULL;
+    if (!curwin->w_p_sms)
+       curwin->w_skipcol = 0;
 
-    curwin->w_skipcol = 0;
-    changed_line_abv_curs();
     return NULL;
 }
 
@@ -4535,9 +4533,12 @@ did_set_winwidth(optset_T *args UNUSED)
     char *
 did_set_wrap(optset_T *args UNUSED)
 {
-    // If 'wrap' is set, set w_leftcol to zero.
+    // Set w_leftcol or w_skipcol to zero.
     if (curwin->w_p_wrap)
        curwin->w_leftcol = 0;
+    else
+       curwin->w_skipcol = 0;
+
     return NULL;
 }
 
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index ef2d3bd4d..f65654dc5 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -2207,4 +2207,20 @@ func Test_set_keyprotocol()
   let &term = term
 endfunc
 
+func Test_set_wrap()
+  " Unsetting 'wrap' when 'smoothscroll' is set does not result in incorrect
+  " cursor position.
+  set wrap smoothscroll scrolloff=5
+
+  call setline(1, ['', 'aaaa'->repeat(500)])
+  20 split
+  20 vsplit
+  norm 2G$
+  redraw
+  set nowrap
+  call assert_equal(2, winline())
+
+  set wrap& smoothscroll& scrolloff&
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index a75c4a675..78c23fca6 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 */
+/**/
+    2081,
 /**/
     2080,
 /**/

-- 
-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1qwpTY-009wQH-2M%40256bit.org.

Raspunde prin e-mail lui