@@ -73,9 +73,12 @@ export class GenericCompleterModel<
73
73
74
74
let matched : boolean ;
75
75
76
+ let filterText : string = null ;
77
+ let filterMatch : StringExt . IMatchResult ;
78
+
76
79
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 ) ;
79
82
matched = ! ! filterMatch ;
80
83
} else {
81
84
matched = true ;
@@ -86,25 +89,32 @@ export class GenericCompleterModel<
86
89
// If the matches are substrings of label, highlight them
87
90
// in this part of the label that can be highlighted (must be a prefix),
88
91
// 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
+ }
90
101
91
- let match = StringExt . matchSumOfSquares ( labelPrefix , query ) ;
92
102
let label : string ;
93
103
let score : number ;
94
104
95
- if ( match ) {
105
+ if ( labelMatch ) {
96
106
// Highlight label text if there's a match
97
107
// there won't be a match if filter text includes additional keywords
98
108
// for easier search that are not a part of the label
99
109
let marked = StringExt . highlight (
100
110
escapeHTML ( item . label ) ,
101
- match . indices ,
111
+ labelMatch . indices ,
102
112
this . _markFragment
103
113
) ;
104
114
label = marked . join ( '' ) ;
105
- score = match . score ;
115
+ score = labelMatch . score ;
106
116
} else {
107
- label = item . label ;
117
+ label = escapeHTML ( item . label ) ;
108
118
score = 0 ;
109
119
}
110
120
// preserve getters (allow for lazily retrieved documentation)
0 commit comments