aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglepnir <glephunter@gmail.com>2025-02-02 18:02:25 +0800
committerGitHub <noreply@github.com>2025-02-02 10:02:25 +0000
commit3e882bf81c5f0761b98d29a6c986026d5962e5f7 (patch)
treeca13711b16a41e9f6a62e38a4728e772375b2d23
parent5bc948c050ce321ed56ff48b0d41e189b1ea4c87 (diff)
downloadrneovim-3e882bf81c5f0761b98d29a6c986026d5962e5f7.tar.gz
rneovim-3e882bf81c5f0761b98d29a6c986026d5962e5f7.tar.bz2
rneovim-3e882bf81c5f0761b98d29a6c986026d5962e5f7.zip
vim-patch:9.1.1069: preinsert text completions not deleted with <C-W>/<C-U> (#32296)
Problem: preinsert text completions not deleted with <C-W>/<C-U> (ddad431, after v9.1.1059) Solution: handle <C-W> or <C-U> specifically and clear the completion (glepnir) fixes: vim/vim#16557 closes: vim/vim#16565 https://github.com/vim/vim/commit/001c26cd6194fba2bfccb06dec30fdc9e1410e62
-rw-r--r--src/nvim/insexpand.c4
-rw-r--r--test/old/testdir/test_ins_complete.vim8
2 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index 44e72b2b01..e21433f5ec 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -2228,6 +2228,10 @@ static bool ins_compl_stop(const int c, const int prev_mode, bool retval)
retval = true;
}
+ if ((c == Ctrl_W || c == Ctrl_U) && ins_compl_preinsert_effect()) {
+ ins_compl_delete(false);
+ }
+
auto_format(false, true);
// Trigger the CompleteDonePre event to give scripts a chance to
diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim
index f276d1e719..2fb1715634 100644
--- a/test/old/testdir/test_ins_complete.vim
+++ b/test/old/testdir/test_ins_complete.vim
@@ -3042,6 +3042,14 @@ function Test_completeopt_preinsert()
call assert_equal("fo ", getline('.'))
call assert_equal(3, col('.'))
+ call feedkeys("She\<C-X>\<C-N>\<C-U>", 'tx')
+ call assert_equal("", getline('.'))
+ call assert_equal(1, col('.'))
+
+ call feedkeys("She\<C-X>\<C-N>\<C-W>", 'tx')
+ call assert_equal("", getline('.'))
+ call assert_equal(1, col('.'))
+
" whole line
call feedkeys("Shello hero\<CR>\<C-X>\<C-L>", 'tx')
call assert_equal("hello hero", getline('.'))