From 53387c55a13bc1013a6ab721d4bd0bd04c6935c4 Mon Sep 17 00:00:00 2001 From: glepnir Date: Mon, 27 May 2024 15:11:01 +0200 Subject: [PATCH] patch 9.1.0447: completion may be wrong when deleting all chars Problem: completion may be wrong when deleting all chars Solution: reset compl_shown_match closes: #14854 Signed-off-by: glepnir Signed-off-by: Christian Brabandt --- src/insexpand.c | 6 ++++++ src/testdir/test_ins_complete.vim | 16 ++++++++-------- src/testdir/test_popup.vim | 2 ++ src/version.c | 2 ++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/insexpand.c b/src/insexpand.c index c420c0ed93..c1374d3e9c 100644 --- a/src/insexpand.c +++ b/src/insexpand.c @@ -1255,6 +1255,12 @@ ins_compl_build_pum(void) if (match_at_original_text(compl_shown_match)) shown_match_ok = TRUE; + if (compl_leader != NULL + && STRCMP(compl_leader, compl_orig_text) == 0 + && shown_match_ok == FALSE) + compl_shown_match = compl_no_select ? compl_first_match + : compl_first_match->cp_next; + i = 0; compl = compl_first_match; do diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim index eb89a15c53..d1b96099b1 100644 --- a/src/testdir/test_ins_complete.vim +++ b/src/testdir/test_ins_complete.vim @@ -630,14 +630,14 @@ func Test_pum_with_preview_win() CheckScreendump let lines =<< trim END - funct Omni_test(findstart, base) - if a:findstart - return col(".") - 1 - endif - return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three", info: "3info"}] - endfunc - set omnifunc=Omni_test - set completeopt+=longest + func Omni_test(findstart, base) + if a:findstart + return col(".") - 1 + endif + return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three", info: "3info"}] + endfunc + set omnifunc=Omni_test + set completeopt+=longest END call writefile(lines, 'Xpreviewscript', 'D') diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim index f5cb8b2a19..1142efc7b7 100644 --- a/src/testdir/test_popup.vim +++ b/src/testdir/test_popup.vim @@ -1175,6 +1175,8 @@ func Test_CompleteChanged() set completeopt=menu,menuone call feedkeys("i\\\\\f", 'tx') call assert_equal('five', g:word) + call feedkeys("i\\\\\f\", 'tx') + call assert_equal('one', g:word) autocmd! AAAAA_Group set complete& completeopt& diff --git a/src/version.c b/src/version.c index ac0bda070a..92088fc95f 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 447, /**/ 446, /**/