Skip to content

Commit 42f9573

Browse files
zeertzjqbrammool
andauthored
vim-patch:9.0.1670: resetting local option to global value is inconsistent (neovim#24185)
Problem: Resetting local option to global value is inconsistent. Solution: Handle "<" specifically for 'scrolloff' and 'sidescrolloff'. (closes vim/vim#12594) vim/vim@bf5f189 Co-authored-by: Bram Moolenaar <[email protected]>
1 parent e85e7fc commit 42f9573

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/nvim/option.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,10 +794,14 @@ static void do_set_num(int opt_idx, int opt_flags, char **argp, int nextchar, co
794794
if (nextchar == '&') {
795795
value = (long)(intptr_t)options[opt_idx].def_val;
796796
} else if (nextchar == '<') {
797-
// For 'undolevels' NO_LOCAL_UNDOLEVEL means to
798-
// use the global value.
799797
if ((long *)varp == &curbuf->b_p_ul && opt_flags == OPT_LOCAL) {
798+
// for 'undolevels' NO_LOCAL_UNDOLEVEL means using the global value
800799
value = NO_LOCAL_UNDOLEVEL;
800+
} else if (opt_flags == OPT_LOCAL
801+
&& ((long *)varp == &curwin->w_p_siso
802+
|| (long *)varp == &curwin->w_p_so)) {
803+
// for 'scrolloff'/'sidescrolloff' -1 means using the global value
804+
value = -1;
801805
} else {
802806
value = *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
803807
}

test/old/testdir/test_options.vim

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,25 +939,33 @@ func Test_local_scrolloff()
939939
wincmd w
940940
call assert_equal(5, &so)
941941
wincmd w
942+
call assert_equal(3, &so)
942943
setlocal so<
943944
call assert_equal(5, &so)
945+
setglob so=8
946+
call assert_equal(8, &so)
947+
call assert_equal(-1, &l:so)
944948
setlocal so=0
945949
call assert_equal(0, &so)
946950
setlocal so=-1
947-
call assert_equal(5, &so)
951+
call assert_equal(8, &so)
948952

949953
call assert_equal(7, &siso)
950954
setlocal siso=3
951955
call assert_equal(3, &siso)
952956
wincmd w
953957
call assert_equal(7, &siso)
954958
wincmd w
959+
call assert_equal(3, &siso)
955960
setlocal siso<
956961
call assert_equal(7, &siso)
962+
setglob siso=4
963+
call assert_equal(4, &siso)
964+
call assert_equal(-1, &l:siso)
957965
setlocal siso=0
958966
call assert_equal(0, &siso)
959967
setlocal siso=-1
960-
call assert_equal(7, &siso)
968+
call assert_equal(4, &siso)
961969

962970
close
963971
set so&

0 commit comments

Comments
 (0)