vim-patch:9.1.1820: completion: some issues with 'acl' (#36007)

Problem:  completion: some issues with 'acl' when "preinsert" and
          "longest" is in 'completeopt' (musonius, after v9.1.1638)
Solution: Fix various issues (see details below) (Girish Palya)

This commit addresses multiple issues in the 'autocompletedelay' behavior with
"preinsert" and "longest":

- Prevents spurious characters from being inserted.
- Ensures the completion menu is not shown until `autocompletedelay` has
  expired.
- Shows the "preinsert" effect immediately.
- Keeps the "preinsert" effect visible even when a character is deleted.

fixes: vim/vim#18443
closes: vim/vim#18460

f77c187277

Co-authored-by: Girish Palya <girishji@gmail.com>
This commit is contained in:
zeertzjq
2025-10-03 21:10:05 +08:00
committed by GitHub
parent 97ab7dd784
commit 8151fc59cf
3 changed files with 150 additions and 4 deletions

View File

@@ -5869,7 +5869,7 @@ func Test_autocomplete_longest()
call Ntest_override("char_avail", 1)
new
inoremap <buffer><F5> <C-R>=GetLine()<CR>
set completeopt=longest autocomplete
set completeopt+=longest autocomplete
call setline(1, ["foobar", "foozbar"])
call feedkeys("Go\<ESC>", 'tx')
@@ -6109,4 +6109,45 @@ func Test_refresh_always_with_fuzzy()
call Ntest_override("char_avail", 0)
endfunc
func Test_autocompletedelay_longest_preinsert()
CheckScreendump
let lines =<< trim [SCRIPT]
call setline(1, ['autocomplete', 'autocomxxx'])
set autocomplete completeopt+=longest autocompletedelay=500
[SCRIPT]
call writefile(lines, 'XTest_autocompletedelay', 'D')
let buf = RunVimInTerminal('-S XTest_autocompletedelay', {'rows': 10})
" No spurious characters when autocompletedelay is in effect
call term_sendkeys(buf, "Goau")
sleep 10m
call term_sendkeys(buf, "toc")
sleep 100m
call VerifyScreenDump(buf, 'Test_autocompletedelay_longest_1', {})
sleep 500m
call VerifyScreenDump(buf, 'Test_autocompletedelay_longest_2', {})
" Deleting a char should still show longest text
call term_sendkeys(buf, "\<Esc>Saut")
sleep 10m
call term_sendkeys(buf, "\<BS>")
sleep 100m
call VerifyScreenDump(buf, 'Test_autocompletedelay_longest_3', {})
sleep 500m
call VerifyScreenDump(buf, 'Test_autocompletedelay_longest_4', {})
" Preinsert
call term_sendkeys(buf, "\<Esc>:set completeopt& completeopt+=preinsert\<CR>")
" Show preinserted text right away but display popup later
call term_sendkeys(buf, "\<Esc>Sau")
sleep 100m
call VerifyScreenDump(buf, 'Test_autocompletedelay_preinsert_1', {})
sleep 500m
call VerifyScreenDump(buf, 'Test_autocompletedelay_preinsert_2', {})
call term_sendkeys(buf, "\<esc>")
call StopVimInTerminal(buf)
endfunc
" vim: shiftwidth=2 sts=2 expandtab nofoldenable