@@ -149,7 +149,7 @@ export class CompletionModel {
149149 this . _filteredItems . push ( item ) ;
150150
151151 // compute score against word
152- const score = CompletionModel . _scoreByHighlight ( item , word , word . toLowerCase ( ) ) ;
152+ const score = CompletionModel . _scoreByHighlight ( item , word ) ;
153153 if ( score > topScore ) {
154154 topScore = score ;
155155 this . _topScoreIdx = this . _filteredItems . length - 1 ;
@@ -166,7 +166,7 @@ export class CompletionModel {
166166
167167 private static _base = 100 ;
168168
169- private static _scoreByHighlight ( item : ICompletionItem , currentWord : string , BLA ) : number {
169+ private static _scoreByHighlight ( item : ICompletionItem , currentWord : string ) : number {
170170 const { highlights, suggestion} = item ;
171171
172172 if ( isFalsyOrEmpty ( highlights ) ) {
@@ -176,7 +176,6 @@ export class CompletionModel {
176176 let caseSensitiveMatches = 0 ;
177177 let caseInsensitiveMatches = 0 ;
178178 let firstMatchStart = 0 ;
179- let notMatching = 0 ;
180179
181180 const len = Math . min ( CompletionModel . _base , suggestion . label . length ) ;
182181 let currentWordOffset = 0 ;
@@ -185,11 +184,7 @@ export class CompletionModel {
185184
186185 const highlight = highlights [ idx ] ;
187186
188- if ( pos < highlight . start ) {
189- // not covered by a highlight
190- notMatching += 1 ;
191-
192- } else if ( pos === highlight . start ) {
187+ if ( pos === highlight . start ) {
193188 // reached a highlight: find highlighted part
194189 // and count case-sensitive /case-insensitive matches
195190 const part = suggestion . label . substring ( highlight . start , highlight . end ) ;
@@ -212,20 +207,19 @@ export class CompletionModel {
212207 firstMatchStart = highlight . start ;
213208 }
214209 idx += 1 ;
210+
215211 if ( idx >= highlights . length ) {
216- notMatching += len - pos ;
217212 break ;
218213 }
219214 }
220215 }
221216
222- // combine the five scoring values into one
217+ // combine the 4 scoring values into one
223218 // value using base_100. Values further left
224219 // are more important
225- return ( CompletionModel . _base ** 4 ) * caseSensitiveMatches
226- + ( CompletionModel . _base ** 3 ) * caseInsensitiveMatches
227- + ( CompletionModel . _base ** 2 ) * ( CompletionModel . _base - firstMatchStart )
228- + ( CompletionModel . _base ** 1 ) * ( CompletionModel . _base - highlights . length )
229- + ( CompletionModel . _base ** 0 ) * ( CompletionModel . _base - notMatching ) ;
220+ return ( CompletionModel . _base ** 3 ) * caseSensitiveMatches
221+ + ( CompletionModel . _base ** 2 ) * caseInsensitiveMatches
222+ + ( CompletionModel . _base ** 1 ) * ( CompletionModel . _base - firstMatchStart )
223+ + ( CompletionModel . _base ** 0 ) * ( CompletionModel . _base - highlights . length ) ;
230224 }
231225}
0 commit comments