mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 22:48:34 +00:00
vim-patch:9.1.1790: completion: Enter does not insert match with "noinsert" (#35917)
Problem: completion: Enter does not insert match with "noinsert".
(Sergey Vlasov)
Solution: Check for compl_shown_match instead of compl_selected_item
(zeertzjq).
fixes: vim/vim#18386
related: vim/vim#1653
closes: vim/vim#18395
ef818ae444
This commit is contained in:
@@ -5451,7 +5451,7 @@ static int ins_compl_next(bool allow_get_expansion, int count, bool insert_match
|
|||||||
|
|
||||||
// Enter will select a match when the match wasn't inserted and the popup
|
// Enter will select a match when the match wasn't inserted and the popup
|
||||||
// menu is visible.
|
// menu is visible.
|
||||||
if (compl_no_insert && !started && compl_selected_item != -1) {
|
if (compl_no_insert && !started && !match_at_original_text(compl_shown_match)) {
|
||||||
compl_enter_selects = true;
|
compl_enter_selects = true;
|
||||||
} else {
|
} else {
|
||||||
compl_enter_selects = !insert_match && compl_match_array != NULL;
|
compl_enter_selects = !insert_match && compl_match_array != NULL;
|
||||||
|
@@ -2364,15 +2364,63 @@ func Test_edit_backspace_smarttab_virtual_text()
|
|||||||
set smarttab&
|
set smarttab&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_edit_CAR()
|
func Test_edit_CAR_with_completion()
|
||||||
set cot=menu,menuone,noselect
|
|
||||||
new
|
new
|
||||||
|
|
||||||
call feedkeys("Shello hero\<CR>h\<C-x>\<C-N>e\<CR>", 'tx')
|
" With "noselect", behavior is the same with and without "noinsert":
|
||||||
call assert_equal(['hello hero', 'he', ''], getline(1, '$'))
|
" Enter inserts a new line when no selection is done or after selecting with
|
||||||
|
" Ctrl-N/P, but does not insert a new line when selecting with cursor keys.
|
||||||
|
for cot in ['menu,menuone,noselect', 'menu,menuone,noselect,noinsert']
|
||||||
|
let &cot = cot
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>e\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'he', ''], getline(1, '$'))
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'h', ''], getline(1, '$'))
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>\<C-N>\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'hello', ''], getline(1, '$'))
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>\<C-N>\<C-N>\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'hero', ''], getline(1, '$'))
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>\<C-N>\<C-P>\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'h', ''], getline(1, '$'))
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>\<Down>\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'hello'], getline(1, '$'))
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>\<Down>\<Down>\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'hero'], getline(1, '$'))
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>\<Down>\<Up>\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'h'], getline(1, '$'))
|
||||||
|
endfor
|
||||||
|
|
||||||
|
" With "noinsert" but not "noselect": like pressing <Down> after "noselect".
|
||||||
|
set cot=menu,menuone,noinsert
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>e\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'hello'], getline(1, '$'))
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'hello'], getline(1, '$'))
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>\<Down>\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'hero'], getline(1, '$'))
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>\<Up>\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'h'], getline(1, '$'))
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>\<C-N>\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'hero', ''], getline(1, '$'))
|
||||||
|
%delete
|
||||||
|
call feedkeys("Shello hero\<CR>h\<C-X>\<C-N>\<C-P>\<CR>", 'tx')
|
||||||
|
call assert_equal(['hello hero', 'h', ''], getline(1, '$'))
|
||||||
|
|
||||||
bw!
|
|
||||||
set cot&
|
set cot&
|
||||||
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user