Repository navigation
Command palette: update the TF-IDF index instead of rebuilding it - #350404
Draft
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Draft
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Conversation
Every query of three or more characters built a new TF-IDF calculator over all commands, splitting and counting the words of every command again on each keystroke. Keep one calculator and only index commands that are new or changed, and delete removed ones. Scores are ordered like the commands before the five-result cut, so ties end up as with a fresh calculator. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot stopped reviewing on behalf of
Federico Brancasi (federicobrancasi) due to an error
November 25, 2026 15:56
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The command palette ranks "similar commands" with TF-IDF once the filter has three or more characters and a command doesn't match by its label.
_getPicksbuilt a newTfIdfCalculatorover all commands for each query, so every keystroke split and counted the words of every command again.This PR keeps one calculator in the provider. Each query reconciles it with the current commands: commands that are new or whose text changed are indexed again, and removed ones are deleted. TF-IDF still runs only when a query needs it.
Results stay those of a freshly built calculator:
updateDocumentsdeletes all keys first, then adds every document), so its words counted twice. Each command now counts once. This can change scores only when two commands share an ID and the filter has several words.The word counts of all commands now stay in memory while the window is open, instead of being rebuilt for each query.
No issue is associated; this came from profiling.
Measured on my machine
Code OSS dev build, scripted scenarios that run commands by typing their names in the command palette; window CPU profile, the same scenarios before and after:
TfIdfCalculator.updateDocumentsHow to test
The two new tests check that similar commands follow added, removed and changed commands, and that ties are cut in command order. They also pass with the old code, which builds a fresh calculator each time; each fails when removed commands aren't deleted or when the order before the cut isn't restored.
./scripts/test.sh --run src/vs/platform/quickinput/test/browser/commandsQuickAccess.test.ts --run src/vs/base/test/common/tfIdf.test.tsnode_modules/.bin/tsc --project ./src/tsconfig.json --noEmit --skipLibChecksrc/vs/platform/agentHost/, from my local Copilot SDK package being older than the one onmain)node_modules/.bin/oxlint <changed files>