gpt4 book ai didi

visual-studio-code - 将 VSCode 中的 "Go to Symbol in Workspace"范围限定为整个工作区

转载 作者:行者123 更新时间:2023-12-04 17:47:11 24 4
gpt4 key购买 nike

我在 VSCode 中的一个 TypeScript 项目中工作,该项目包含多个模块。 “转到工作区中的符号”(CTRL+T) 命令似乎将其自身限定为工作区的本地子集,尽管它的名称如此(这意味着它的搜索应该是全局的)。

假设我在模块 A 中定义了 Foo(),它公开了一个被模块 B 使用的 foo.d.ts 文件,我有这个目录结构

 root
|
+-- A (folder)
|
+-- B (folder)

我看到以下行为:

  1. 如果我正在编辑 A 中的文件并搜索 #Foo,它将带我到 Foo() 的实际定义。好。
  2. 但如果我在 B 中编辑一个文件并搜索 #Foo,它只会带我到 A 导出的 foo.d.ts - 我有手动导航到 A 以找到 Foo() 的实际定义。

我真的希望 #Foo 的意思是“显示我工作区中任何位置的符号 Foo 的所有实例。”有没有办法强制这种行为?

最佳答案

预览功能:vscode v1.45 应该改进跨 javascript 和 typescript 项目的符号搜索,而无需打开所有文件。参见 https://github.com/microsoft/vscode/issues/11026https://github.com/microsoft/vscode/issues/11026 (js/ts 工作区符号搜索仅在加载了 js/ts 文件时有效)。

Added with a new setting: typescript.workspaceSymbols.scope. Valid values are:

allOpenProjects — (default) search all opened projects for symbols. Requires TS 3.9+

currentProject — Only search the current project

  • 来自第一个链接。

#11026 Improved this. You no longer need to have a JS/TS file open for workspace symbol search to work and we can now search across all JS/TS projects you know about.

If you are using TS 3.9, all projects should be searched by default

On older TS versions, only the current project should be searched. If using TS 3.9, you can switch to only search the current project by setting: "typescript.workspaceSymbols.scope": "currentProject"

However we still require you to have opened a JS/TS file

  • 来自第二个链接。

另请参阅 v1.45 发行说明:https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_45.md#workspace-symbol-search-in-all-open-typescriptjavascript-projects

When using TypeScript 3.9+, VS Code's workspace symbol search now includes results from all opened JavaScript and TypeScript projects by default. We previously only searched the project of the currently active file.

This is controlled by the new "typescript.workspaceSymbols.scope" setting. To revert to the old behavior, just set: "typescript.workspaceSymbols.scope": "currentProject".


要查看您拥有的 typescript 版本以及如何安装更新版本,请参阅 https://stackoverflow.com/a/39676463/836330 .和 https://stackoverflow.com/a/47087772/836330很好。


v1.46 发行说明:searching for symbols across projects in a workspace

JS/TS Go to Symbol in workspace includes all opened projects

By default, workspace symbol search for JavaScript and TypeScript now search all opened jsconfig and tsconfig projects. It previously only included search results from the project the focused file belonged to.

This behavior is controlled by the typescript.workspaceSymbols.scope setting and requires TS 3.9+. To revert the to previous behavior and only search the current project, just set "typescript.workspaceSymbols.scope": "currentProject"

关于visual-studio-code - 将 VSCode 中的 "Go to Symbol in Workspace"范围限定为整个工作区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47931087/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com