vim-patch:9.1.0469: Cannot have buffer-local value for 'completeopt'

Problem:  Cannot have buffer-local value for 'completeopt'
          (Nick Jensen).
Solution: Make 'completeopt' global-local (zeertzjq).

Also for some reason test Test_ColonEight_MultiByte seems to be failing
sporadically now. Let's mark it as flaky.

fixes: vim/vim#5487
closes: vim/vim#14922

529b9ad62a
This commit is contained in:
zeertzjq
2024-06-06 05:50:44 +08:00
parent c235a063d6
commit 1d4e894403
12 changed files with 137 additions and 40 deletions

View File

@@ -884,6 +884,74 @@ func Test_complete_with_longest()
bwipe!
endfunc
" Test for buffer-local value of 'completeopt'
func Test_completeopt_buffer_local()
set completeopt=menu
new
call setline(1, ['foofoo', 'foobar', 'foobaz', ''])
call assert_equal('', &l:completeopt)
call assert_equal('menu', &completeopt)
call assert_equal('menu', &g:completeopt)
setlocal bufhidden=hide
enew
call setline(1, ['foofoo', 'foobar', 'foobaz', ''])
call assert_equal('', &l:completeopt)
call assert_equal('menu', &completeopt)
call assert_equal('menu', &g:completeopt)
setlocal completeopt+=fuzzy,noinsert
call assert_equal('menu,fuzzy,noinsert', &l:completeopt)
call assert_equal('menu,fuzzy,noinsert', &completeopt)
call assert_equal('menu', &g:completeopt)
call feedkeys("Gccf\<C-X>\<C-N>bz\<C-Y>", 'tnix')
call assert_equal('foobaz', getline('.'))
setlocal completeopt=
call assert_equal('', &l:completeopt)
call assert_equal('menu', &completeopt)
call assert_equal('menu', &g:completeopt)
call feedkeys("Gccf\<C-X>\<C-N>\<C-Y>", 'tnix')
call assert_equal('foofoo', getline('.'))
setlocal completeopt+=longest
call assert_equal('menu,longest', &l:completeopt)
call assert_equal('menu,longest', &completeopt)
call assert_equal('menu', &g:completeopt)
call feedkeys("Gccf\<C-X>\<C-N>\<C-X>\<C-Z>", 'tnix')
call assert_equal('foo', getline('.'))
setlocal bufhidden=hide
buffer #
call assert_equal('', &l:completeopt)
call assert_equal('menu', &completeopt)
call assert_equal('menu', &g:completeopt)
call feedkeys("Gccf\<C-X>\<C-N>\<C-Y>", 'tnix')
call assert_equal('foofoo', getline('.'))
setlocal completeopt+=fuzzy,noinsert
call assert_equal('menu,fuzzy,noinsert', &l:completeopt)
call assert_equal('menu,fuzzy,noinsert', &completeopt)
call assert_equal('menu', &g:completeopt)
call feedkeys("Gccf\<C-X>\<C-N>bz\<C-Y>", 'tnix')
call assert_equal('foobaz', getline('.'))
buffer #
call assert_equal('menu,longest', &l:completeopt)
call assert_equal('menu,longest', &completeopt)
call assert_equal('menu', &g:completeopt)
call feedkeys("Gccf\<C-X>\<C-N>\<C-X>\<C-Z>", 'tnix')
call assert_equal('foo', getline('.'))
setlocal bufhidden=wipe
buffer! #
bwipe!
call assert_equal('', &l:completeopt)
call assert_equal('menu', &completeopt)
call assert_equal('menu', &g:completeopt)
set completeopt&
endfunc
" Test for completing words following a completed word in a line
func Test_complete_wrapscan()