feat(core): improve @file autocomplete to prioritize filenames#21064
feat(core): improve @file autocomplete to prioritize filenames#21064
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the user experience of the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request improves file search autocomplete by changing the fuzzy search logic to prioritize matches closer to the end of a path. The changes in fileSearch.ts introduce new tiebreakers for fzf and set it to search from right-to-left. While this correctly prioritizes filenames over files in deeper directories (e.g., hooks.ts over .../hooks/index.ts), I've found a case where it can prioritize a directory over a file (e.g., hooks/ over hooks.ts). My review includes suggestions to add another tiebreaker to fix this and update the test assertions accordingly to fully align with the goal of prioritizing filenames.
|
Size Change: +1.16 kB (0%) Total Size: 25.9 MB
ℹ️ View Unchanged
|
Summary
Improves the behavior of the
@file autocomplete feature to prioritize actual filenames and folder names over matching parent directory structures, providing a more intuitive search experience.Details
Updated the
AsyncFzfconfiguration inRecursiveFileSearchto evaluate matches right-to-left (forward: false) and introduced a sophisticated multi-stage tiebreaker sequence to refine result ranking:byBasenamePrefix: Prioritizes matches that start at the beginning of the actual filename or folder name. For example, a search forhookswill now correctly rank the folder/src/hooks/higher than a file deep inside it like/src/hooks/index.ts.byMatchPosFromEnd: Scores matches based on their distance from the end of the file path, favoring matches that are closer to the extension/filename.byLengthAsc: Prefers shorter, cleaner paths to break final ties.These changes ensure that searching for a string like
hooksconsistently rankshooks.tsor ahooks/directory at the top, rather than files where the term only appears as part of a parent directory name.Related Issues
Fixes #21063
How to Validate
npm test -w @google/gemini-cli-corenpm test -w @google/gemini-cli -- src/ui/hooks/useAtCompletion.test.ts@hookscorrectly prioritizes the filename/folder name over the path.Pre-Merge Checklist