@@ -1264,7 +1264,8 @@ ins_compl_build_pum(void)
12641264 int max_fuzzy_score = 0 ;
12651265 unsigned int cur_cot_flags = get_cot_flags ();
12661266 int compl_no_select = (cur_cot_flags & COT_NOSELECT ) != 0 ;
1267- int compl_fuzzy_match = (cur_cot_flags & COT_FUZZY ) != 0 ;
1267+ int fuzzy_nosort = (cur_cot_flags & COT_NOSORT ) != 0 ;
1268+ int fuzzy_filter = fuzzy_nosort || (cur_cot_flags & COT_FUZZY ) != 0 ;
12681269 compl_T * match_head = NULL ;
12691270 compl_T * match_tail = NULL ;
12701271 compl_T * match_next = NULL ;
@@ -1289,13 +1290,13 @@ ins_compl_build_pum(void)
12891290 compl -> cp_in_match_array = FALSE;
12901291 // When 'completeopt' contains "fuzzy" and leader is not NULL or empty,
12911292 // set the cp_score for later comparisons.
1292- if (compl_fuzzy_match && compl_leader .string != NULL && compl_leader .length > 0 )
1293+ if (fuzzy_filter && compl_leader .string != NULL && compl_leader .length > 0 )
12931294 compl -> cp_score = fuzzy_match_str (compl -> cp_str .string , compl_leader .string );
12941295
12951296 if (!match_at_original_text (compl )
12961297 && (compl_leader .string == NULL
12971298 || ins_compl_equal (compl , compl_leader .string , (int )compl_leader .length )
1298- || (compl_fuzzy_match && compl -> cp_score > 0 )))
1299+ || (fuzzy_filter && compl -> cp_score > 0 )))
12991300 {
13001301 ++ compl_match_arraysize ;
13011302 compl -> cp_in_match_array = TRUE;
@@ -1305,7 +1306,7 @@ ins_compl_build_pum(void)
13051306 match_tail -> cp_match_next = compl ;
13061307 match_tail = compl ;
13071308
1308- if (!shown_match_ok && !compl_fuzzy_match )
1309+ if (!shown_match_ok && !fuzzy_filter )
13091310 {
13101311 if (compl == compl_shown_match || did_find_shown_match )
13111312 {
@@ -1321,19 +1322,21 @@ ins_compl_build_pum(void)
13211322 shown_compl = compl ;
13221323 cur = i ;
13231324 }
1324- else if (compl_fuzzy_match )
1325+ else if (fuzzy_filter )
13251326 {
13261327 if (i == 0 )
13271328 shown_compl = compl ;
13281329 // Update the maximum fuzzy score and the shown match
13291330 // if the current item's score is higher
1330- if (compl -> cp_score > max_fuzzy_score )
1331+ if (! fuzzy_nosort && compl -> cp_score > max_fuzzy_score )
13311332 {
13321333 did_find_shown_match = TRUE;
13331334 max_fuzzy_score = compl -> cp_score ;
13341335 if (!compl_no_select )
13351336 compl_shown_match = compl ;
13361337 }
1338+ else if (fuzzy_nosort && i == 0 && !compl_no_select )
1339+ compl_shown_match = shown_compl ;
13371340
13381341 if (!shown_match_ok && compl == compl_shown_match && !compl_no_select )
13391342 {
@@ -1344,7 +1347,7 @@ ins_compl_build_pum(void)
13441347 i ++ ;
13451348 }
13461349
1347- if (compl == compl_shown_match && !compl_fuzzy_match )
1350+ if (compl == compl_shown_match && !fuzzy_filter )
13481351 {
13491352 did_find_shown_match = TRUE;
13501353
@@ -1389,7 +1392,7 @@ ins_compl_build_pum(void)
13891392 compl = match_next ;
13901393 }
13911394
1392- if (compl_fuzzy_match && compl_leader .string != NULL && compl_leader .length > 0 )
1395+ if (fuzzy_filter && ! fuzzy_nosort && compl_leader .string != NULL && compl_leader .length > 0 )
13931396 {
13941397 for (i = 0 ; i < compl_match_arraysize ; i ++ )
13951398 compl_match_array [i ].pum_idx = i ;
0 commit comments