-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix sorting problem in QuickFileOpenService #10694
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@colin-grant-work unfortunately the changes do not work for me, the file-search is broken when I tried in the browser and electron. The following error is reported multiple times:
quick-file-open.ts:247 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'score')
at score (/home/evinfug/workspaces/theia/examples/electron/lib/packages_file-search_lib_browser_file-search-frontend-module_js.bundle.js:346)
at Array.compareByLabelScore (/home/evinfug/workspaces/theia/examples/electron/lib/packages_file-search_lib_browser_file-search-frontend-module_js.bundle.js:355)
at compareWithDiscriminators (/home/evinfug/workspaces/theia/examples/electron/lib/packages_file-search_lib_browser_file-search-frontend-module_js.bundle.js:523)
at QuickFileOpenService.compareItems (/home/evinfug/workspaces/theia/examples/electron/lib/packages_file-search_lib_browser_file-search-frontend-module_js.bundle.js:361)
at /home/evinfug/workspaces/theia/examples/electron/lib/packages_file-search_lib_browser_file-search-frontend-module_js.bundle.js:305
at Array.sort (<anonymous>)
at handler (/home/evinfug/workspaces/theia/examples/electron/lib/packages_file-search_lib_browser_file-search-frontend-module_js.bundle.js:305)
Steps to Reproduce:
- start the application with
theia
as a workspace - search for
pack
- the file-search is broken
@vince-fugnitto, good catch. The perils of only doing searches that work in a small workspace (and of trusting the declared types...)! I've pushed a commit that handles the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm that the changes work as expected following the update, and the tests successfully pass 👍
I verified using a large workspace with exact, good and invalid results and it works fine, even with recent results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I did a smoke test as well.
What it does
There were a couple of problems in the sort function for the file quick pick and in the tests for them:
A positive returns means left after right, so these values are reversed.
theia/examples/api-tests/src/file-search.spec.js
Lines 41 to 42 in be4eba9
I've replaced the return expectations with actual passes through a sort function so that we're guaranteed to mirror the actual behavior of the function in its intended context of use.
To test whether L before R, these should also be reversed (but since the test expectations were reversed, the tests passed)
theia/packages/file-search/src/browser/quick-file-open.ts
Line 272 in be4eba9
Fuzzy scores can be greater than
Scores.max
(1000), so imperfect matches could get a lead over perfect matches.theia/packages/file-search/src/browser/quick-file-open.ts
Line 254 in be4eba9
How to test
Review checklist
Reminder for reviewers