]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0832: :set doesn't work for 'cot' and 'bkc' after :setlocal v9.1.0832
authorzeertzjq <zeertzjq@outlook.com>
Sun, 3 Nov 2024 08:10:50 +0000 (09:10 +0100)
committerChristian Brabandt <cb@256bit.org>
Sun, 3 Nov 2024 08:10:50 +0000 (09:10 +0100)
Problem:  :set doesn't work for 'cot' and 'bkc' after :setlocal.
Solution: clear the local flags when using :set (zeertzjq).

closes: #15981

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/optionstr.c
src/testdir/test_ins_complete.vim
src/version.c

index 0554c0eb248b49d93ad951e38298508e53f28e17..7c589e9173cfd66077482bb2c73972a30b78a151 100644 (file)
@@ -1146,6 +1146,9 @@ did_set_backupcopy(optset_T *args)
        bkc = curbuf->b_p_bkc;
        flags = &curbuf->b_bkc_flags;
     }
+    else if (!(args->os_flags & OPT_GLOBAL))
+       // When using :set, clear the local flags.
+       curbuf->b_bkc_flags = 0;
 
     if ((args->os_flags & OPT_LOCAL) && *bkc == NUL)
        // make the local value empty: use the global value
@@ -1619,6 +1622,9 @@ did_set_completeopt(optset_T *args UNUSED)
        cot = curbuf->b_p_cot;
        flags = &curbuf->b_cot_flags;
     }
+    else if (!(args->os_flags & OPT_GLOBAL))
+       // When using :set, clear the local flags.
+       curbuf->b_cot_flags = 0;
 
     if (check_opt_strings(cot, p_cot_values, TRUE) != OK)
        return e_invalid_argument;
index df254847ee5093f80d33415c7981e05489f25cc3..8b478a190eff0cb4e4c94ccf50ec2551299931df 100644 (file)
@@ -875,6 +875,46 @@ func Test_completeopt_buffer_local()
   call assert_equal('menu', &completeopt)
   call assert_equal('menu', &g:completeopt)
 
+  new | only
+  call setline(1, ['foofoo', 'foobar', 'foobaz', ''])
+  set completeopt&
+  setlocal completeopt=menu,fuzzy,noinsert
+  setglobal completeopt=menu,longest
+  call assert_equal('menu,fuzzy,noinsert', &completeopt)
+  call assert_equal('menu,fuzzy,noinsert', &l:completeopt)
+  call assert_equal('menu,longest', &g:completeopt)
+  call feedkeys("Gccf\<C-X>\<C-N>bz\<C-Y>", 'tnix')
+  call assert_equal('foobaz', getline('.'))
+  setlocal bufhidden=wipe
+  new | only!
+  call setline(1, ['foofoo', 'foobar', 'foobaz', ''])
+  call assert_equal('menu,longest', &completeopt)
+  call assert_equal('menu,longest', &g:completeopt)
+  call assert_equal('', &l:completeopt)
+  call feedkeys("Gccf\<C-X>\<C-N>\<C-X>\<C-Z>", 'tnix')
+  call assert_equal('foo', getline('.'))
+  bwipe!
+
+  new | only
+  call setline(1, ['foofoo', 'foobar', 'foobaz', ''])
+  set completeopt&
+  setlocal completeopt=menu,fuzzy,noinsert
+  set completeopt=menu,longest
+  call assert_equal('menu,longest', &completeopt)
+  call assert_equal('menu,longest', &g:completeopt)
+  call assert_equal('', &l:completeopt)
+  call feedkeys("Gccf\<C-X>\<C-N>\<C-X>\<C-Z>", 'tnix')
+  call assert_equal('foo', getline('.'))
+  setlocal bufhidden=wipe
+  new | only!
+  call setline(1, ['foofoo', 'foobar', 'foobaz', ''])
+  call assert_equal('menu,longest', &completeopt)
+  call assert_equal('menu,longest', &g:completeopt)
+  call assert_equal('', &l:completeopt)
+  call feedkeys("Gccf\<C-X>\<C-N>\<C-X>\<C-Z>", 'tnix')
+  call assert_equal('foo', getline('.'))
+  bwipe!
+
   set completeopt&
 endfunc
 
index 3e8bfbd7b989faa5e546a8526c5254183a288b42..e4625857246514c2bc6025c88cd5ea33a9a3f32e 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    832,
 /**/
     831,
 /**/