如何在VS Code中禁用跳转到定义时的预览?

48
当我在VS Code中点击以获取定义时,我只想直接跳转到那个地方,不想要覆盖层。
我可以禁用它吗?

enter image description here


有一个“Peek Definition”功能,它显示了一个覆盖层,“转到定义”对我来说很有效。如果您使用“ctrl +左键单击”,它是否按预期工作? - Aliaksandr Sushkevich
我在使用Mac电脑,似乎无法让这个组合起作用。 - dagda1
9
你找到解决方案了吗?这很烦人。 - Bright Lee
5
很遗憾,我不喜欢它。 - dagda1
1
我发现这与TypeScript有关。https://github.com/Microsoft/vscode/issues/51489 - Bright Lee
当ts 3.0发布时,它将被修复。也有一个解决方法,但我会等待。https://dev59.com/pazka4cB1Zd3GeqP5DjK - Bright Lee
7个回答

44

当发现多个定义时,修改settings.json会出现这种情况。

"editor.gotoLocation.multipleDefinitions": "goto"


在此输入图片描述


20

我也在寻找同样的东西,看到这篇帖子还没有答案,所以觉得可以试着回答一下。

如果你在用户设置文件中添加了以下内容,vscode将不再预览定义:

"editor.gotoLocation.multiple": "goto"

6
VScode提示:此设置已过时,请改用单独的设置,例如“editor.editor.gotoLocation.multipleDefinitions”或“editor.editor.gotoLocation.multipleImplementations”。请注意不要改变原来的意思。 - hamncheez

7

对我来说,上述所有方法都无法解决从typescript文件导入的jsx文件的问题。

  • 评论中所述,这是一个与typescript相关的问题,三年前似乎已经修复了,但我猜它仍然存在。

我通过进入 F1 > Preferences: Open User Settings > 搜索 peek > 尝试将每个设置更改为goto而不是peek来解决这个问题。

在我这种情况下,需要更改 Multiple References 设置。

enter image description here


6
默认情况下,如果一个符号有多个可能的定义,VS Code会显示这个峰视图和定义列表。在您的示例中,可能是以下内容:
- 重新分配中configurationCommon的定义 - 所需文件中configurationCommon的定义
您可以通过设置"editor.gotoLocation.multiple": "goto"来更改此默认行为。这将直接跳转到定义。如果有多个定义,则可以再次按下f12以跳转到下一个定义。状态栏项会显示定义的总数。

enter image description here


非常感谢,这解决了我的问题!此外,在1.80.x版本中,该设置已被弃用,取而代之的是5个不同的设置:"editor.gotoLocation.multipleDefinitions": "goto", "editor.gotoLocation.multipleDeclarations": "goto", "editor.gotoLocation.multipleImplementations": "goto","editor.gotoLocation.multipleReferences": "goto","editor.gotoLocation.multipleTypeDefinitions": "goto"。 - Onkeltem

4

对于较新的版本,请设置:

"editor.definitionLinkOpensInPeek": false


0
你可能想要查看以下设置(下面是从defaultSettings.json中复制的):
// "editor.defaultColorDecorators": true,
// "markdown.editor.pasteUrlAsFormattedLink.enabled": true,
// Controls the behavior the 'Go to Declaration'-command when multiple target locations exist.
//  - peek: Show Peek view of the results (default)
//  - gotoAndPeek: Go to the primary result and show a Peek view
//  - goto: Go to the primary result and enable Peek-less navigation to others
"editor.gotoLocation.multipleDeclarations": "peek",

// Controls the behavior the 'Go to Definition'-command when multiple target locations exist.
//  - peek: Show Peek view of the results (default)
//  - gotoAndPeek: Go to the primary result and show a Peek view
//  - goto: Go to the primary result and enable Peek-less navigation to others
"editor.gotoLocation.multipleDefinitions": "peek",

// Controls the behavior the 'Go to Implementations'-command when multiple target locations exist.
//  - peek: Show Peek view of the results (default)
//  - gotoAndPeek: Go to the primary result and show a Peek view
//  - goto: Go to the primary result and enable Peek-less navigation to others
"editor.gotoLocation.multipleImplementations": "peek",

// Controls the behavior the 'Go to References'-command when multiple target locations exist.
//  - peek: Show Peek view of the results (default)
//  - gotoAndPeek: Go to the primary result and show a Peek view
//  - goto: Go to the primary result and enable Peek-less navigation to others
"editor.gotoLocation.multipleReferences": "peek",

// Controls the behavior the 'Go to Type Definition'-command when multiple target locations exist.
//  - peek: Show Peek view of the results (default)
//  - gotoAndPeek: Go to the primary result and show a Peek view
//  - goto: Go to the primary result and enable Peek-less navigation to others
"editor.gotoLocation.multipleTypeDefinitions": "peek",

-1

在我的电脑上(Mac),如果我按下CMD + 点击或 F12 在一个方法上,它会将我带到定义的 Peek 视图,但是 CMD+F12 会直接带我到实现而没有出现 Peek。

我试图找到解决方法,更改 CMD+点击的行为以转到实现,但似乎还没有解决方案?

VSCode文档显示默认设置为转到定义,无法修改: https://code.visualstudio.com/docs/editor/editingevolved


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接