vim-patch:9.1.1797: completion: autocompletion can be improved

Problem:  completion: autocompletion can be improved
Solution: Add support for "longest" and "preinsert" in 'autocomplete';
          add preinserted() (Girish Palya)

* Add support for "longest" in 'completeopt' when 'autocomplete'
  is enabled. (Note: the cursor position does not change automatically
  when 'autocomplete' is enabled.)
* Add support for "preinsert" when 'autocomplete' is enabled. Ensure
  "preinsert" works the same with and without 'autocomplete'
* introduce the preinserted() Vim script function, useful for defining
  custom key mappings.

fixes: vim/vim#18314
closes: vim/vim#18387

c05335082a

Co-authored-by: Girish Palya <girishji@gmail.com>
This commit is contained in:
zeertzjq
2025-09-27 09:09:03 +08:00
parent 4896178863
commit 7b9c063d11
11 changed files with 381 additions and 130 deletions

View File

@@ -1496,18 +1496,18 @@ describe('completion', function()
-- During delay wait, user can open menu using CTRL_N completion
feed('<Esc>')
command('set completeopt=menuone,preinsert')
command('set completeopt=menuone,longest')
feed('Sf<C-N>')
screen:expect([[
foo |
foobar |
foobarbaz |
f{102:^oo} |
{12:foo }{1: }|
foo^ |
{4:foo }{1: }|
{4:foobar }{1: }|
{4:foobarbaz }{1: }|
{1:~ }|*2
{5:-- Keyword completion (^N^P) }{6:match 1 of 3} |
{5:-- Keyword completion (^N^P) }{19:Back at original} |
]])
-- After the menu is open, ^N/^P and Up/Down should not delay