Skip to content

Commit bf5f189

Browse files
committed
patch 9.0.1670: resetting local option to global value is inconsistent
Problem: Resetting local option to global value is inconsistent. Solution: Handle "<" specifically for 'scrolloff' and 'sidescrolloff'. (closes #12594)
1 parent 19e6c4f commit bf5f189

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/option.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,10 +2135,14 @@ do_set_option_numeric(
21352135
((flags & P_VI_DEF) || cp_val) ? VI_DEFAULT : VIM_DEFAULT];
21362136
else if (nextchar == '<')
21372137
{
2138-
// For 'undolevels' NO_LOCAL_UNDOLEVEL means to
2139-
// use the global value.
21402138
if ((long *)varp == &curbuf->b_p_ul && opt_flags == OPT_LOCAL)
2139+
// for 'undolevels' NO_LOCAL_UNDOLEVEL means using the global value
21412140
value = NO_LOCAL_UNDOLEVEL;
2141+
else if (opt_flags == OPT_LOCAL
2142+
&& ((long *)varp == &curwin->w_p_siso
2143+
|| (long *)varp == &curwin->w_p_so))
2144+
// for 'scrolloff'/'sidescrolloff' -1 means using the global value
2145+
value = -1;
21422146
else
21432147
value = *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
21442148
}

src/testdir/test_options.vim

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,25 +954,33 @@ func Test_local_scrolloff()
954954
wincmd w
955955
call assert_equal(5, &so)
956956
wincmd w
957+
call assert_equal(3, &so)
957958
setlocal so<
958959
call assert_equal(5, &so)
960+
setglob so=8
961+
call assert_equal(8, &so)
962+
call assert_equal(-1, &l:so)
959963
setlocal so=0
960964
call assert_equal(0, &so)
961965
setlocal so=-1
962-
call assert_equal(5, &so)
966+
call assert_equal(8, &so)
963967

964968
call assert_equal(7, &siso)
965969
setlocal siso=3
966970
call assert_equal(3, &siso)
967971
wincmd w
968972
call assert_equal(7, &siso)
969973
wincmd w
974+
call assert_equal(3, &siso)
970975
setlocal siso<
971976
call assert_equal(7, &siso)
977+
setglob siso=4
978+
call assert_equal(4, &siso)
979+
call assert_equal(-1, &l:siso)
972980
setlocal siso=0
973981
call assert_equal(0, &siso)
974982
setlocal siso=-1
975-
call assert_equal(7, &siso)
983+
call assert_equal(4, &siso)
976984

977985
close
978986
set so&

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1670,
698700
/**/
699701
1669,
700702
/**/

0 commit comments

Comments
 (0)