Skip to content

Commit 6437997

Browse files
girishjichrisbra
authored andcommitted
patch 9.1.1918: completion: crash with fuzzy completion
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 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 4b4a893 commit 6437997

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

src/insexpand.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5710,11 +5710,14 @@ ins_compl_get_exp(pos_T *ini)
57105710
}
57115711
may_trigger_modechanged();
57125712

5713-
if (is_nearest_active() && !ins_compl_has_preinsert())
5714-
sort_compl_match_list(cp_compare_nearest);
5713+
if (match_count > 0)
5714+
{
5715+
if (is_nearest_active() && !ins_compl_has_preinsert())
5716+
sort_compl_match_list(cp_compare_nearest);
57155717

5716-
if ((get_cot_flags() & COT_FUZZY) && ins_compl_leader_len() > 0)
5717-
ins_compl_fuzzy_sort();
5718+
if ((get_cot_flags() & COT_FUZZY) && ins_compl_leader_len() > 0)
5719+
ins_compl_fuzzy_sort();
5720+
}
57185721

57195722
return match_count;
57205723
}

src/testdir/test_ins_complete.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3705,6 +3705,22 @@ func Test_complete_fuzzy_collect()
37053705
set completeopt& cfc& cpt&
37063706
endfunc
37073707

3708+
" Issue #18752
3709+
func Test_complete_fuzzy_collect_multiwin()
3710+
new
3711+
set completefuzzycollect=keyword,files,whole_line
3712+
set completeopt=fuzzy
3713+
3714+
vnew
3715+
call setline(1, ["completeness,", "compatibility", "Composite", "Omnipotent"])
3716+
wincmd p
3717+
call feedkeys("Somp\<C-P>\<Esc>0", 'tx!')
3718+
call assert_equal('Omnipotent', getline('.'))
3719+
3720+
bw!
3721+
set completeopt& cfc&
3722+
endfunc
3723+
37083724
func Test_cfc_with_longest()
37093725
new
37103726
set completefuzzycollect=keyword,files,whole_line

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ static char *(features[]) =
729729

730730
static int included_patches[] =
731731
{ /* Add new patch number below this line */
732+
/**/
733+
1918,
732734
/**/
733735
1917,
734736
/**/

0 commit comments

Comments
 (0)