Skip to content

Commit b39408e

Browse files
committed
fix: Correct exact match detection in fzf algorithm
The previous condition 'sidx === 0 && eidx === textLength' incorrectly identified subsequence matches spanning the entire text as exact matches. For example, searching 'path' in 'pxyath' would trigger the boost incorrectly. The correct condition 'textLength === patternLength' ensures that when all pattern characters match as a subsequence and both strings have the same length, it must be an exact match.
1 parent 06f2293 commit b39408e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

static/app/utils/search/fzf.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export function fzf(text: string, pattern: string, caseSensitive: boolean): Resu
137137
let [score, matches] = calculateScore(text, pattern, sidx, eidx, caseSensitive);
138138

139139
// Boost exact matches (text === pattern) so they rank above partial matches
140-
if (sidx === 0 && eidx === textLength) {
140+
if (textLength === patternLength) {
141141
score += scoreMatch;
142142
}
143143

0 commit comments

Comments
 (0)