Skip to content

Added maxResults argument to provideWorkspaceSymbols - #193524

Closed
Sauvik Nath (Sauvikn98) wants to merge 4 commits into
microsoft:mainfrom
Sauvikn98:main
Closed

Sauvik Nath (Sauvikn98) wants to merge 4 commits into
microsoft:mainfrom
Sauvikn98:main

Conversation

@Sauvikn98

@Sauvikn98 Sauvik Nath (Sauvikn98) commented Sep 19, 2023 •

Copy link
Copy Markdown

With Reference to Issue #191725

JS/TS's workspace symbol provider currently limits the number of workspace symbols it returns to 256. This is done for performance reasons. In large repos, it is costly to collect and transmit tens of thousands of workspace symbols, especially when you consider that users typically only look at the first 10 or so

However there are cases where you really do want every single workspace symbol in a workspace, for example when an extension uses the vscode.executeWorkspaceSymbolProvider command. Today there is no way for an extension to get all JS/TS symbols as the VS Code api dose not provide a way to override TS Server's limit of 256 symbols per response

Proposal

Add a new maxResults argument to provideWorkspaceSymbols. This would have two benefits:

In the normal go to symbol in workspace flow, we could set maxResults = 500 or some other number. This would let extensions that observe this new argument improve their performance by not collecting and transmitting tons and tons of symbols

With the vscode.executeWorkspaceSymbolProvider command or other cases where something else besides VS Code is calling into provideWorkspaceSymbols, we provide a mechanism to explicitly request every single workspace symbol instead of leaving it up to language servers to determine how many symbols they should return for good performance

@Sauvikn98 Sauvik Nath (Sauvikn98) changed the title Added maxResults argument to provideWorkspaceSymbols. Issue Number #191725 Added maxResults argument to provideWorkspaceSymbols Sep 19, 2023
@Sauvikn98

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="S&S Inc"

@jrieken

Copy link
Copy Markdown
Contributor

👎 for an API change and hardcoded numbers.

JS/TS's workspace symbol provider currently limits the number of workspace symbols it returns to 256.

Matt Bierner (@mjbvz) I don't know if that's true and iff why it was done. Such a low number seems extremely conservative, completions happily return 10000+ items and I think we should expect that symbol search can handle equally large numbers

@mjbvz

Copy link
Copy Markdown
Contributor

Johannes Rieken (@jrieken) Yes this is a real problem (the PR is a copy paste of what I wrote in the linked issue)

Transmission may be fast enough but generating a list of every possible symbol in a TS proj is expensive, especially on large projects or when node modules are included. Even after optimizing it was still not fast enough

So instead we decided to be pragmatic and optimize for how workspace symbols are shown to users. So far users have not complained about only seeing 256 at a time. You can keep typing to get more results. We only return 256 items max but always search the entire set of symbols

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Closing per above discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants