test: Add test case for exact match prioritization in fzf#110685
test: Add test case for exact match prioritization in fzf#110685
Conversation
This test documents the expected behavior that exact matches should score higher than partial matches. Currently fails, demonstrating the bug where 'path' scores the same as 'binary_path' and 'code.file.path'. Related to GH-110680 Co-authored-by: Jonas <JonasBa@users.noreply.github.com>
48da2f5 to
8b60072
Compare
Adds integration test verifying that exact matches are prioritized over partial matches when using CompactSelect with search enabled. Test uses the same real-world examples (binary_path, code.file.path, path) to verify the behavior at the component level. Currently skipped until fix from GH-110680 is implemented. Co-authored-by: Jonas <JonasBa@users.noreply.github.com>
Boost fzf score by scoreMatch when text exactly equals the pattern, so exact matches rank above partial matches with the same characters. Unskips and tightens the two related tests to assert each result by index rather than via find/filter loops. Fixes GH-110680 Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Exact match detection condition is too broad
- Replaced the condition with 'textLength === patternLength' which correctly identifies exact matches when combined with the subsequence match.
Or push these changes by commenting:
@cursor push b39408e01b
Preview (b39408e01b)
diff --git a/static/app/utils/search/fzf.tsx b/static/app/utils/search/fzf.tsx
--- a/static/app/utils/search/fzf.tsx
+++ b/static/app/utils/search/fzf.tsx
@@ -137,7 +137,7 @@
let [score, matches] = calculateScore(text, pattern, sidx, eidx, caseSensitive);
// Boost exact matches (text === pattern) so they rank above partial matches
- if (sidx === 0 && eidx === textLength) {
+ if (textLength === patternLength) {
score += scoreMatch;
}This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
The previous condition `sidx === 0 && eidx === textLength` also boosted subsequence matches that happen to span the full text (e.g. pattern `az` in `abcz`). Adding `textLength === patternLength` ensures the boost only applies when text and pattern are identical. Co-Authored-By: Claude <noreply@anthropic.com>
|
@cursoragent fix the following lint error |
|
Fixed! I've resolved the lint error by separating the destructuring: • Changed The |
Fixes eslint prefer-const warning. The matches variable from calculateScore is never reassigned, so it should be const. Co-authored-by: Jonas <JonasBa@users.noreply.github.com>




Summary
Adds test cases to demonstrate and document the expected behavior for exact match prioritization in the fzf fuzzy search algorithm, both at the algorithm level and at the CompactSelect component level.
Test Cases
1. Unit Test (
fzf.spec.tsx)Tests the fzf algorithm directly with the pattern
"path"against:binary_pathcode.file.pathpathVerifies that the exact match scores higher than partial matches.
2. Integration Test (
compactSelect.spec.tsx)Tests CompactSelect with search enabled using the same real-world examples from the Slack discussion. Verifies that when searching for
"path", the exact match option appears first in the sorted results.Current Behavior
Both tests are currently skipped to avoid blocking CI. When unskipped locally, they fail because all three options receive the same score (104), confirming the issue described in the Slack thread about exact matches not being boosted properly.
Next Steps
Once the fix from #110680 is applied, these tests should be unskipped and will serve as regression tests to ensure exact matches are properly prioritized at both the algorithm and component levels.
Related
Slack Thread