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

@@ -1591,6 +1591,7 @@ describe('completion', function()
feed('<esc>')
end)
-- oldtest: Test_fuzzy_select_item_when_acl()
it([[first item isn't selected with "fuzzy" and 'acl']], function()
screen:try_resize(60, 10)
source([[
@@ -1634,4 +1635,98 @@ describe('completion', function()
{5:-- INSERT --} |
]])
end)
-- oldtest: Test_autocompletedelay_longest_preinsert()
it("'autocompletedelay' with 'completeopt' longest/preinsert", function()
source([[
call setline(1, ['autocomplete', 'autocomxxx'])
set autocomplete completeopt+=longest autocompletedelay=500
]])
screen:expect([[
^autocomplete |
autocomxxx |
{1:~ }|*5
|
]])
screen.timeout = 400
-- No spurious characters when autocompletedelay is in effect
feed('Goau')
screen:expect([[
autocomplete |
autocomxxx |
au{102:^tocom} |
{1:~ }|*4
{5:-- INSERT --} |
]])
feed('toc')
screen:expect([[
autocomplete |
autocomxxx |
autoc{102:^om} |
{1:~ }|*4
{5:-- INSERT --} |
]])
vim.uv.sleep(500)
screen:expect([[
autocomplete |
autocomxxx |
autoc{102:^om} |
{4:autocomxxx }{1: }|
{4:autocomplete }{1: }|
{1:~ }|*2
{5:-- INSERT --} |
]])
-- Deleting a char should still show longest text
feed('<Esc>Saut')
screen:expect([[
autocomplete |
autocomxxx |
aut{102:^ocom} |
{1:~ }|*4
{5:-- INSERT --} |
]])
feed('<BS>')
screen:expect([[
autocomplete |
autocomxxx |
au{102:^tocom} |
{1:~ }|*4
{5:-- INSERT --} |
]])
vim.uv.sleep(500)
screen:expect([[
autocomplete |
autocomxxx |
au{102:^tocom} |
{4:autocomxxx }{1: }|
{4:autocomplete }{1: }|
{1:~ }|*2
{5:-- INSERT --} |
]])
-- Preinsert
command('set completeopt& completeopt+=preinsert')
-- Show preinserted text right away but display popup later
feed('<Esc>Sau')
screen:expect([[
autocomplete |
autocomxxx |
au{102:^tocomplete} |
{1:~ }|*4
{5:-- INSERT --} |
]])
vim.uv.sleep(500)
screen:expect([[
autocomplete |
autocomxxx |
au{102:^tocomplete} |
{12:autocomplete }{1: }|
{4:autocomxxx }{1: }|
{1:~ }|*2
{5:-- INSERT --} |
]])
end)
end)