]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0489: default completion may break with fuzzy v9.1.0489
authorglepnir <glephunter@gmail.com>
Sat, 15 Jun 2024 13:13:05 +0000 (15:13 +0200)
committerChristian Brabandt <cb@256bit.org>
Sat, 15 Jun 2024 13:27:09 +0000 (15:27 +0200)
Problem:  default completion may break with fuzzy
Solution: check that completion_match_array is not null
          (glepnir)

closes: #15010

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/insexpand.c
src/testdir/test_ins_complete.vim
src/version.c

index 7b9a5116d00cdadf54005eb97e102f0edf70bf5b..e3127416584b979c1a4f1a6a947ae4b77157154d 100644 (file)
@@ -4155,8 +4155,8 @@ find_next_completion_match(
     {
        if (compl_shows_dir_forward() && compl_shown_match->cp_next != NULL)
        {
-           compl_shown_match = !compl_fuzzy_match ? compl_shown_match->cp_next
-                                               : find_comp_when_fuzzy();
+           compl_shown_match = compl_fuzzy_match && compl_match_array != NULL
+                       ? find_comp_when_fuzzy() : compl_shown_match->cp_next;
            found_end = (compl_first_match != NULL
                    && (is_first_match(compl_shown_match->cp_next)
                        || is_first_match(compl_shown_match)));
@@ -4165,8 +4165,8 @@ find_next_completion_match(
                && compl_shown_match->cp_prev != NULL)
        {
            found_end = is_first_match(compl_shown_match);
-           compl_shown_match = !compl_fuzzy_match ? compl_shown_match->cp_prev
-                                                  : find_comp_when_fuzzy();
+           compl_shown_match = compl_fuzzy_match && compl_match_array != NULL
+                       ? find_comp_when_fuzzy() : compl_shown_match->cp_prev;
            found_end |= is_first_match(compl_shown_match);
        }
        else
index 9f689fefe234ca5ad8be580a5499f2b36ac70389..51e3c1b5b6394ebb65411f68e630fe084b4a1930 100644 (file)
@@ -2573,6 +2573,16 @@ func Test_complete_fuzzy_match()
   call feedkeys("S\<C-x>\<C-o>fb\<C-n>", 'tx')
   call assert_equal('fooBaz', g:word)
 
+  " avoid break default completion behavior
+  set completeopt=fuzzy,menu
+  call setline(1, ['hello help hero h'])
+  exe "norm! A\<C-X>\<C-N>"
+  call assert_equal('hello help hero hello', getline('.'))
+  set completeopt+=noinsert
+  call setline(1, ['hello help hero h'])
+  exe "norm! A\<C-X>\<C-N>"
+  call assert_equal('hello help hero h', getline('.'))
+
   " clean up
   set omnifunc=
   bw!
index 61532287da6b04da280397fc1e5712c5f7f803a3..f153bfb07e04294f25af14d8be39aa63046b0ae8 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    489,
 /**/
     488,
 /**/