From 07785ea9c5595f379f2cac2ce8ffa95244e3d8e3 Mon Sep 17 00:00:00 2001 From: glepnir Date: Wed, 19 Feb 2025 13:40:46 +0800 Subject: vim-patch:9.1.1121: Enter does not insert newline with "noselect" Problem: Enter does not insert newline with "noselect" when the pum is visible (lifepillar) Solution: When Enter is pressed and no complete-item is selected, ins_compl_prep returns false, and the edit function continues processing Enter to insert a new line. (glepnir) fixes: vim/vim#1653 closes: vim/vim#16653 https://github.com/vim/vim/commit/07f0dbe3aa326fdf4d0f1b1cf7d79df89e91fc6e Co-authored-by: glepnir --- test/functional/editor/completion_spec.lua | 10 ++++++---- test/functional/legacy/edit_spec.lua | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) (limited to 'test/functional') diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index 7c68de272b..fdf6917b53 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -506,19 +506,21 @@ describe('completion', function() ]]) end) - it('Enter selects original text after adding leader', function() + it('Enter selects original text after adding leader and insert newline', function() feed('iJ') poke_eventloop() feed('u') poke_eventloop() feed('') - expect('Ju') + expect([[Ju +]]) feed('') poke_eventloop() -- The behavior should be the same when completion has been interrupted, -- which can happen interactively if the completion function is slow. - feed('SJu') - expect('Ju') + feed('ggVGSJu') + expect([[Ju +]]) end) end) diff --git a/test/functional/legacy/edit_spec.lua b/test/functional/legacy/edit_spec.lua index d2ce80efda..eee232f2c8 100644 --- a/test/functional/legacy/edit_spec.lua +++ b/test/functional/legacy/edit_spec.lua @@ -92,4 +92,28 @@ describe('edit', function() | ]]) end) + + -- oldtest: Test_edit_CAR() + it('insert a newline when pressing Enter, even if the pum is visible', function() + local screen = Screen.new(10, 6) + command('set cot=menu,menuone,noselect') + feed('Shello herohe') + screen:expect([[ + hello hero | + he^ | + {4:hello }| + {4:hero }| + {1:~ }| + {5:--} | + ]]) + + feed('') + screen:expect([[ + hello hero | + he | + ^ | + {1:~ }|*2 + {5:-- INSERT --}| + ]]) + end) end) -- cgit