]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1670: resetting local option to global value is inconsistent v9.0.1670
authorBram Moolenaar <Bram@vim.org>
Tue, 27 Jun 2023 20:51:07 +0000 (21:51 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 27 Jun 2023 20:51:07 +0000 (21:51 +0100)
Problem:    Resetting local option to global value is inconsistent.
Solution:   Handle "<" specifically for 'scrolloff' and 'sidescrolloff'.
            (closes #12594)

src/option.c
src/testdir/test_options.vim
src/version.c

index e9c6a50addd0ebfd3849b99749c789207d9b321e..3050dbc4170ebdc988e2fc035b580dcb0f0a33ec 100644 (file)
@@ -2135,10 +2135,14 @@ do_set_option_numeric(
            ((flags & P_VI_DEF) || cp_val) ? VI_DEFAULT : VIM_DEFAULT];
     else if (nextchar == '<')
     {
-       // For 'undolevels' NO_LOCAL_UNDOLEVEL means to
-       // use the global value.
        if ((long *)varp == &curbuf->b_p_ul && opt_flags == OPT_LOCAL)
+           // for 'undolevels' NO_LOCAL_UNDOLEVEL means using the global value
            value = NO_LOCAL_UNDOLEVEL;
+       else if (opt_flags == OPT_LOCAL
+                   && ((long *)varp == &curwin->w_p_siso
+                    || (long *)varp == &curwin->w_p_so))
+           // for 'scrolloff'/'sidescrolloff' -1 means using the global value
+           value = -1;
        else
            value = *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
     }
index 015ecc122ddc228ce229169892b08b83f20614bf..0de5e25f9ade88c2cc5090cd8b52313da0af6a4f 100644 (file)
@@ -954,12 +954,16 @@ func Test_local_scrolloff()
   wincmd w
   call assert_equal(5, &so)
   wincmd w
+  call assert_equal(3, &so)
   setlocal so<
   call assert_equal(5, &so)
+  setglob so=8
+  call assert_equal(8, &so)
+  call assert_equal(-1, &l:so)
   setlocal so=0
   call assert_equal(0, &so)
   setlocal so=-1
-  call assert_equal(5, &so)
+  call assert_equal(8, &so)
 
   call assert_equal(7, &siso)
   setlocal siso=3
@@ -967,12 +971,16 @@ func Test_local_scrolloff()
   wincmd w
   call assert_equal(7, &siso)
   wincmd w
+  call assert_equal(3, &siso)
   setlocal siso<
   call assert_equal(7, &siso)
+  setglob siso=4
+  call assert_equal(4, &siso)
+  call assert_equal(-1, &l:siso)
   setlocal siso=0
   call assert_equal(0, &siso)
   setlocal siso=-1
-  call assert_equal(7, &siso)
+  call assert_equal(4, &siso)
 
   close
   set so&
index 316649fdd1ef2a191a7bee3d5eacb7a24b80dba8..bc2b0b502f21f5b34a632bc250d505f39fefdbd5 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1670,
 /**/
     1669,
 /**/