@@ -106,6 +106,7 @@ struct compl_S
106106 int cp_flags ; // CP_ values
107107 int cp_number ; // sequence number
108108 int cp_score ; // fuzzy match score
109+ int cp_in_match_array ; // collected by compl_match_array
109110 int cp_user_abbr_hlattr ; // highlight attribute for abbr
110111 int cp_user_kind_hlattr ; // highlight attribute for kind
111112};
@@ -1282,6 +1283,7 @@ ins_compl_build_pum(void)
12821283
12831284 do
12841285 {
1286+ compl -> cp_in_match_array = FALSE;
12851287 // When 'completeopt' contains "fuzzy" and leader is not NULL or empty,
12861288 // set the cp_score for later comparisons.
12871289 if (compl_fuzzy_match && compl_leader .string != NULL && compl_leader .length > 0 )
@@ -1293,6 +1295,7 @@ ins_compl_build_pum(void)
12931295 || (compl_fuzzy_match && compl -> cp_score > 0 )))
12941296 {
12951297 ++ compl_match_arraysize ;
1298+ compl -> cp_in_match_array = TRUE;
12961299 if (match_head == NULL )
12971300 match_head = compl ;
12981301 else
@@ -3259,11 +3262,12 @@ get_complete_info(list_T *what_list, dict_T *retdict)
32593262#define CI_WHAT_ITEMS 0x04
32603263#define CI_WHAT_SELECTED 0x08
32613264#define CI_WHAT_INSERTED 0x10
3265+ #define CI_WHAT_MATCHES 0x20
32623266#define CI_WHAT_ALL 0xff
32633267 int what_flag ;
32643268
32653269 if (what_list == NULL )
3266- what_flag = CI_WHAT_ALL ;
3270+ what_flag = CI_WHAT_ALL & ~ CI_WHAT_MATCHES ;
32673271 else
32683272 {
32693273 what_flag = 0 ;
@@ -3282,6 +3286,8 @@ get_complete_info(list_T *what_list, dict_T *retdict)
32823286 what_flag |= CI_WHAT_SELECTED ;
32833287 else if (STRCMP (what , "inserted" ) == 0 )
32843288 what_flag |= CI_WHAT_INSERTED ;
3289+ else if (STRCMP (what , "matches" ) == 0 )
3290+ what_flag |= CI_WHAT_MATCHES ;
32853291 }
32863292 }
32873293
@@ -3291,19 +3297,23 @@ get_complete_info(list_T *what_list, dict_T *retdict)
32913297 if (ret == OK && (what_flag & CI_WHAT_PUM_VISIBLE ))
32923298 ret = dict_add_number (retdict , "pum_visible" , pum_visible ());
32933299
3294- if (ret == OK && (what_flag & CI_WHAT_ITEMS || what_flag & CI_WHAT_SELECTED ))
3300+ if (ret == OK && (what_flag & CI_WHAT_ITEMS || what_flag & CI_WHAT_SELECTED
3301+ || what_flag & CI_WHAT_MATCHES ))
32953302 {
32963303 list_T * li = NULL ;
32973304 dict_T * di ;
32983305 compl_T * match ;
32993306 int selected_idx = -1 ;
3307+ int has_items = what_flag & CI_WHAT_ITEMS ;
3308+ int has_matches = what_flag & CI_WHAT_MATCHES ;
33003309
3301- if (what_flag & CI_WHAT_ITEMS )
3310+ if (has_items || has_matches )
33023311 {
33033312 li = list_alloc ();
33043313 if (li == NULL )
33053314 return ;
3306- ret = dict_add_list (retdict , "items" , li );
3315+ ret = dict_add_list (retdict , (has_matches && !has_items )
3316+ ? "matches" : "items" , li );
33073317 }
33083318 if (ret == OK && what_flag & CI_WHAT_SELECTED )
33093319 if (compl_curr_match != NULL && compl_curr_match -> cp_number == -1 )
@@ -3316,7 +3326,8 @@ get_complete_info(list_T *what_list, dict_T *retdict)
33163326 {
33173327 if (!match_at_original_text (match ))
33183328 {
3319- if (what_flag & CI_WHAT_ITEMS )
3329+ if (has_items
3330+ || (has_matches && match -> cp_in_match_array ))
33203331 {
33213332 di = dict_alloc ();
33223333 if (di == NULL )
@@ -3329,13 +3340,16 @@ get_complete_info(list_T *what_list, dict_T *retdict)
33293340 dict_add_string (di , "menu" , match -> cp_text [CPT_MENU ]);
33303341 dict_add_string (di , "kind" , match -> cp_text [CPT_KIND ]);
33313342 dict_add_string (di , "info" , match -> cp_text [CPT_INFO ]);
3343+ if (has_matches && has_items )
3344+ dict_add_bool (di , "match" , match -> cp_in_match_array );
33323345 if (match -> cp_user_data .v_type == VAR_UNKNOWN )
33333346 // Add an empty string for backwards compatibility
33343347 dict_add_string (di , "user_data" , (char_u * )"" );
33353348 else
33363349 dict_add_tv (di , "user_data" , & match -> cp_user_data );
33373350 }
3338- if (compl_curr_match != NULL && compl_curr_match -> cp_number == match -> cp_number )
3351+ if (compl_curr_match != NULL
3352+ && compl_curr_match -> cp_number == match -> cp_number )
33393353 selected_idx = list_idx ;
33403354 list_idx += 1 ;
33413355 }
0 commit comments