]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1918: completion: crash with fuzzy completion v9.1.1918
authorGirish Palya <girishji@gmail.com>
Sun, 16 Nov 2025 18:30:42 +0000 (18:30 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 16 Nov 2025 18:30:42 +0000 (18:30 +0000)
Problem:  completion: crash with fuzzy completion
          (Christian Brabandt)
Solution: When completion candidates are gathered from a different
          window, and when completing `<c-p>`, linked list should be
          sorted only after all items are collected (Girish Palya).

fixes: #18752
closes: #18756

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

index f3cbeb2531e11a0363e6d7322ae52344a6862c2f..8ec549ae0202902004b083d1bb21248b1b5fef04 100644 (file)
@@ -5710,11 +5710,14 @@ ins_compl_get_exp(pos_T *ini)
     }
     may_trigger_modechanged();
 
-    if (is_nearest_active() && !ins_compl_has_preinsert())
-       sort_compl_match_list(cp_compare_nearest);
+    if (match_count > 0)
+    {
+       if (is_nearest_active() && !ins_compl_has_preinsert())
+           sort_compl_match_list(cp_compare_nearest);
 
-    if ((get_cot_flags() & COT_FUZZY) && ins_compl_leader_len() > 0)
-       ins_compl_fuzzy_sort();
+       if ((get_cot_flags() & COT_FUZZY) && ins_compl_leader_len() > 0)
+           ins_compl_fuzzy_sort();
+    }
 
     return match_count;
 }
index 84d1236e3caf08790ac5d9b50ca034320aca9d51..77be5b42e7ac1d32c7825a7af91f227a0e225e25 100644 (file)
@@ -3705,6 +3705,22 @@ func Test_complete_fuzzy_collect()
   set completeopt& cfc& cpt&
 endfunc
 
+" Issue #18752
+func Test_complete_fuzzy_collect_multiwin()
+  new
+  set completefuzzycollect=keyword,files,whole_line
+  set completeopt=fuzzy
+
+  vnew
+  call setline(1, ["completeness,", "compatibility", "Composite", "Omnipotent"])
+  wincmd p
+  call feedkeys("Somp\<C-P>\<Esc>0", 'tx!')
+  call assert_equal('Omnipotent', getline('.'))
+
+  bw!
+  set completeopt& cfc&
+endfunc
+
 func Test_cfc_with_longest()
   new
   set completefuzzycollect=keyword,files,whole_line
index 1a6093ac92f179a7f3db9c5a61cf00aef4448cb2..ebb3f3974def4cafe744c2a3a6d0a3e187f33314 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1918,
 /**/
     1917,
 /**/