mirror of
https://github.com/neovim/neovim.git
synced 2025-10-03 16:36:30 +00:00
vim-patch:9.1.1800: completion: strange behaviour with 'ac' completeopt=longest,preinsert
Problem: completion: strange behaviour with 'ac'
completeopt=longest,preinsert (zeertzjq)
Solution: Let preinsert take precedence (Girish Palya)
fixes: vim/vim#18410
closes: vim/vim#18428
d35e5e4237
Co-authored-by: Girish Palya <girishji@gmail.com>
This commit is contained in:
@@ -2736,7 +2736,8 @@ bool ins_compl_prep(int c)
|
||||
// Set "compl_get_longest" when finding the first matches.
|
||||
if (ctrl_x_mode_not_defined_yet()
|
||||
|| (ctrl_x_mode_normal() && !compl_started)) {
|
||||
compl_get_longest = (get_cot_flags() & kOptCotFlagLongest) != 0;
|
||||
compl_get_longest = (get_cot_flags() & kOptCotFlagLongest) != 0
|
||||
&& !ins_compl_has_autocomplete();
|
||||
compl_used_match = true;
|
||||
}
|
||||
|
||||
|
@@ -1496,18 +1496,18 @@ describe('completion', function()
|
||||
|
||||
-- During delay wait, user can open menu using CTRL_N completion
|
||||
feed('<Esc>')
|
||||
command('set completeopt=menuone,longest')
|
||||
command('set completeopt=menuone')
|
||||
feed('Sf<C-N>')
|
||||
screen:expect([[
|
||||
foo |
|
||||
foobar |
|
||||
foobarbaz |
|
||||
foo^ |
|
||||
{4:foo }{1: }|
|
||||
{12:foo }{1: }|
|
||||
{4:foobar }{1: }|
|
||||
{4:foobarbaz }{1: }|
|
||||
{1:~ }|*2
|
||||
{5:-- Keyword completion (^N^P) }{19:Back at original} |
|
||||
{5:-- Keyword completion (^N^P) }{6:match 1 of 3} |
|
||||
]])
|
||||
|
||||
-- After the menu is open, ^N/^P and Up/Down should not delay
|
||||
|
@@ -5834,7 +5834,7 @@ func Test_autocompletedelay()
|
||||
call VerifyScreenDump(buf, 'Test_autocompletedelay_6', {})
|
||||
|
||||
" During delay wait, user can open menu using CTRL_N completion
|
||||
call term_sendkeys(buf, "\<Esc>:set completeopt=menuone,longest\<CR>")
|
||||
call term_sendkeys(buf, "\<Esc>:set completeopt=menuone\<CR>")
|
||||
call term_sendkeys(buf, "Sf\<C-N>")
|
||||
call VerifyScreenDump(buf, 'Test_autocompletedelay_7', {})
|
||||
|
||||
@@ -5984,6 +5984,16 @@ 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'
|
||||
" takes precedence
|
||||
%delete
|
||||
set autocomplete completeopt+=longest,preinsert
|
||||
call setline(1, ['foobar', 'foofoo', 'foobaz', ''])
|
||||
call feedkeys("G", 'tx')
|
||||
call DoTest("f", 'foobar', 2)
|
||||
call assert_equal(1, g:preinserted)
|
||||
|
||||
" Undo
|
||||
%delete _
|
||||
let &l:undolevels = &l:undolevels
|
||||
normal! ifoo
|
||||
|
Reference in New Issue
Block a user