vim-patch:9.1.1810: completion: "longest" doesn't work for manual completion with 'ac'

Problem:  completion: "longest" doesn't work for manual completion when
          'autocomplete' is on (after 9.1.1800).
Solution: Only reset compl_get_longest when enabling autocompletion
          (zeertzjq).

closes: vim/vim#18430

b3966d6a8e
This commit is contained in:
zeertzjq
2025-09-30 09:11:07 +08:00
parent f30a33858f
commit 756e55dc49
2 changed files with 23 additions and 4 deletions

View File

@@ -5984,7 +5984,7 @@ func Test_autocomplete_longest()
call feedkeys("Go\<ESC>", 'tx')
call DoTest("f\<C-N>\<C-N>\<BS>\<BS>\<BS>\<BS>", 'foo', 3)
" Issue #18410: When both 'preinsert' and 'longest' are set, 'preinsert'
" Issue #18410: When both "preinsert" and "longest" are set, "preinsert"
" takes precedence
%delete
set autocomplete completeopt+=longest,preinsert
@@ -6035,6 +6035,21 @@ func Test_autocomplete_longest()
%delete _
delfunc CheckUndo
" Check that behavior of "longest" in manual completion is unchanged.
for ac in [v:false, v:true]
let &ac = ac
set completeopt=menuone,longest
call feedkeys("Ssign u\<C-X>\<C-V>", 'tx')
call assert_equal('sign un', getline('.'))
call feedkeys("Ssign u\<C-X>\<C-V>\<C-V>", 'tx')
call assert_equal('sign undefine', getline('.'))
call feedkeys("Ssign u\<C-X>\<C-V>\<C-V>\<C-V>", 'tx')
call assert_equal('sign unplace', getline('.'))
call feedkeys("Ssign u\<C-X>\<C-V>\<C-V>\<C-V>\<C-V>", 'tx')
call assert_equal('sign u', getline('.'))
%delete
endfor
bw!
set cot& autocomplete&
delfunc GetLine