Vscode: "Go To Symbol in Workspace" command provides inconvenient UX in some cases.

Created on 10 Dec 2016  路  16Comments  路  Source: microsoft/vscode

  • VSCode Version: Code 1.7.2 (7ba55c5860b152d999dda59393ca3ebeb1b5c85f, 2016-11-21T22:06:37.428Z)
  • OS Version: Windows_NT ia32 6.3.9600
  • Extensions:

|Extension|Author|Version|
|---|---|---|
|vscode-file-peek|abierbaum|1.0.1|
|html-snippets|abusaidm|0.0.18|
|project-manager|alefragnani|0.12.2|
|path-intellisense|christian-kohler|1.1.0|
|githistory|donjayamanne|0.1.2|
|vscode-generate-getter-setter|DSKWRK|0.4.1|
|EditorConfig|EditorConfig|0.3.4|
|tslint|eg2|0.7.1|
|RelativePath|jakob101|0.11.0|
|docthis|joelday|0.3.5|
|Angular2|johnpapa|1.0.2|
|refactorix|krizzdewizz|0.3.0|
|debugger-for-chrome|msjsdiag|2.3.2|
|typescript-hero|rbbit|0.11.0|
|vscode-icons|robertohuertasm|4.0.5|
|vscode-terminal-here|Tyriar|0.0.5|
|gitblame|waderyan|1.3.0|


"Go To Symbol in Workspace" command (CTRL+T) is one of the most useful commands used for navigation in workspace, but in some cases it can be not so useful as it could be. Here is a couple of examples (usually I use VS code for typescript projects):

  1. When I run vs code and there are no opened files, CTRL+T doesn't provide any result. For new users of VS code it's a bit unobvious fact, that you should open some file before perform some navigation.
  2. If I have several tsconfig.json files in my workspace (atleast two), it performs search only within nearest one relative to an editing file. So, I can't see any classes and interfaces from the first project if I'm editing a file from the second project.

I suppose that this a bit strange behaviour origins from Typescript Language Service (tsserver), but can these issues be resolved on VS Code side? Most of users expect that "Go To Symbol in Workspace" performs search through whole workspace folder and through all projects in this workspace.

Thanks for awesome editor, it's really great!

*duplicate javascript typescript

Most helpful comment

When I run vs code and there are no opened files, CTRL+T doesn't provide any result. For new users of VS code it's a bit unobvious fact, that you should open some file before perform some navigation.

Indeed. All my dev team just tried the new VSCode version to check out if this "broken" feature has been "repaired"; but we was quite disappointed seeing that "Goto symbol in workspace" still doesn't return any result.

If I understand well, "Goto symbol in workspace" is only looking in opened files ? Maybe should it be renamed to "Goto symbol in opened files" instead ?

All 16 comments

That's a problem specific to TypeScripts WorkspaceSymbolProvider and how tsserver works

When I run vs code and there are no opened files, CTRL+T doesn't provide any result. For new users of VS code it's a bit unobvious fact, that you should open some file before perform some navigation.

This also confused me. I have a habit of closing all open files every now and then, but then CTRL+T wont work, so now I mostly use Go to file... (CTRL+P) to avoid this confusion all together.

I don't know how tsserver works, but wouldn't it be possible to use the project root folder as the tsserver root? Especially considering I have a tsconfig.json there.

When I run vs code and there are no opened files, CTRL+T doesn't provide any result. For new users of VS code it's a bit unobvious fact, that you should open some file before perform some navigation.

Indeed. All my dev team just tried the new VSCode version to check out if this "broken" feature has been "repaired"; but we was quite disappointed seeing that "Goto symbol in workspace" still doesn't return any result.

If I understand well, "Goto symbol in workspace" is only looking in opened files ? Maybe should it be renamed to "Goto symbol in opened files" instead ?

I would love to be able to search for any symbol from the project and have them appear first, before other NPM modules or external imports.

Years since first reported
Still no commits?
How come, VScode Team?

I run into the same problem. cmd+t can only search in opened files and maybe some related files.

The same confusing... I expect that Go To Symbol in Workspace is not dependent on opened files.
Seems like the extensions that implement WorkspaceSymbolProvider doing it incorrect cause they must provide searching in a whole workspace but in the most cases they are using DocumentSymbolProvider (inside WorkspaceSymbolProvider) to cache the symbols and populate a list of available symbols, but DocumentSymbolProvider is executing by vscode only for opened files. Even in builtin extensions https://github.com/Microsoft/vscode/blob/558c694d473142173ebe6e1d3fb5be8d84d24ba3/extensions/markdown-language-features/src/features/workspaceSymbolProvider.ts#L134
But another question is: should vscode provide an API to help to index a workspace (eg auto-indexation and populating the symbols in the workspace)?

This issue is a deal breaker for me and why i can't switch from full blown visual studio, i work on a project that's had hundreds of devs over 5 years so there are thousands of scripts, some with class names that don't match exactly the file name, some files have multiple classes/structs/enums in them and not being able to navigate to them quickly, or at all in the case where a coworker knows the name of a symbol but not the name of the file it was in (This of course also an issue because the actual search panel itself is slow and filtering it is not very intuitive)

@jrieken this is incredibly annoying but easy enough to work around. How do we fix this? What specifically is it that the tsserver does that is preventing this feature from working as if I had all my TS file opened in the first place? For the most time it does find stuff but whenever you switch workspace or restart VS code it's back to nothing.

Anyone looking into fixing this?

I would be happy to help if someone can point to the cause in the source.

has this been looked into, ever since?

This has been open for a while! Why can't I search for symbol when no file is open in workspace?

Not searching all projects is a duplicate of #11026 (fixed with TS 3.9)

Search requiring a file is a duplicate of #11173

@mjbvz does it work only with TS?
What's about python/es6 classes for example?

This issue (and the linked ones) are about JS/TS

If you see the same issue but for Python, please file an issue against the python extension

Was this page helpful?
0 / 5 - 0 ratings