@@ -73,9 +73,12 @@ export class GenericCompleterModel<
7373
7474 let matched : boolean ;
7575
76+ let filterText : string = null ;
77+ let filterMatch : StringExt . IMatchResult ;
78+
7679 if ( query ) {
77- const filterText = this . getFilterText ( item ) ;
78- let filterMatch = StringExt . matchSumOfSquares ( filterText , query ) ;
80+ filterText = this . getFilterText ( item ) ;
81+ filterMatch = StringExt . matchSumOfSquares ( filterText , query ) ;
7982 matched = ! ! filterMatch ;
8083 } else {
8184 matched = true ;
@@ -86,25 +89,32 @@ export class GenericCompleterModel<
8689 // If the matches are substrings of label, highlight them
8790 // in this part of the label that can be highlighted (must be a prefix),
8891 // which is intended to avoid highlighting matches in function arguments etc.
89- const labelPrefix = escapeHTML ( this . getHighlightableLabelRegion ( item ) ) ;
92+ let labelMatch : StringExt . IMatchResult ;
93+ if ( query ) {
94+ let labelPrefix = escapeHTML ( this . getHighlightableLabelRegion ( item ) ) ;
95+ if ( labelPrefix == filterText ) {
96+ labelMatch = filterMatch ;
97+ } else {
98+ labelMatch = StringExt . matchSumOfSquares ( labelPrefix , query ) ;
99+ }
100+ }
90101
91- let match = StringExt . matchSumOfSquares ( labelPrefix , query ) ;
92102 let label : string ;
93103 let score : number ;
94104
95- if ( match ) {
105+ if ( labelMatch ) {
96106 // Highlight label text if there's a match
97107 // there won't be a match if filter text includes additional keywords
98108 // for easier search that are not a part of the label
99109 let marked = StringExt . highlight (
100110 escapeHTML ( item . label ) ,
101- match . indices ,
111+ labelMatch . indices ,
102112 this . _markFragment
103113 ) ;
104114 label = marked . join ( '' ) ;
105- score = match . score ;
115+ score = labelMatch . score ;
106116 } else {
107- label = item . label ;
117+ label = escapeHTML ( item . label ) ;
108118 score = 0 ;
109119 }
110120 // preserve getters (allow for lazily retrieved documentation)
0 commit comments