我正在使用 Visual Studio Code 和 Rust 语言。使用
rust-analyzer
扩展安装了对 Rust 的支持。我试图找到如何摆脱我没有在任何地方设置的这种奇怪的灰色背景颜色。我不知道这个设置是怎么叫的。
我的自定义配置如下。
{
"workbench.colorTheme": "Visual Studio Light",
"rust-analyzer.check.command": "clippy",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"debug.allowBreakpointsEverywhere": true,
"hexeditor.columnWidth": 8,
"hexeditor.showDecodedText": true,
"hexeditor.defaultEndianness": "little",
"hexeditor.inspectorType": "aside",
"lldb.launch.expressions": "native",
"lldb.launch.initCommands": [
"settings set target.x86-disassembly-flavor intel"
],
"debug.autoExpandLazyVariables": true,
"lldb.showDisassembly": "always",
"editor.minimap.enabled": false,
"files.eol": "\r\n",
"workbench.colorCustomizations": {
"terminal.background": "#242424",
"terminal.foreground": "#ffffff"
},
"editor.tokenColorCustomizations": {
"functions": "#ff9900",
"strings": "#007c0a",
"comments": "#b3b3b3",
"textMateRules": [
{
"scope": "keyword.operator",
"settings": {
"foreground": "#FF0000",
}
},
{
"scope": "entity.name.type",
"settings": {
"foreground": "#f700ff"
}
}
]
}
}
即使我删除整个
editor.tokenColorCustomizations
设置,灰色背景也不会消失。所以,看起来这个灰色的东西并不是令牌定制。那是什么?
更新
我做了一些实验,发现如下。
如果我关闭IDE并再次打开它,灰色的东西就消失了,但是一旦我运行或开始调试,这个东西就会出现并且无论我做什么都不会消失。这意味着停止应用程序不会隐藏这些值。
禁用
debug.autoExpandLazyVariables
也无济于事。
Debug: Inline Values
设置为auto
,意思是调试时显示值,调试后隐藏值。但出于某种原因,这些值在运行后并未隐藏。是 VS Code IDE 的错误吗?
谢谢。
那些灰色的框被称为“镶嵌提示”。从那里,搜索发现了这个问题:Is there setting to change the color of inlay hints?配置多年来发生了变化,但最近评论中的示例有效:
"workbench.colorCustomizations": {
"editorInlayHint.foreground": "#888a",
"editorInlayHint.background": "#0000",
},
感谢@kmdreko,这些灰色的东西原来是inlay hints.
但是……貌似是IDE的bug。当应用程序未运行时,应隐藏这些所谓的“嵌入提示”。至少,它们隐藏在我使用的除 Microsoft Visual Studio Code 之外的所有 IDE 中。所以,我认为它是一个错误,即使它是 Microsoft 开发人员的“功能”。
所以,对我有用的解决方案是将嵌入提示的行为设置为
offUnlessPressed
。因此,通过这种方式,我可以通过按住 Ctrl
+ Alt
组合键来手动显示和隐藏这些提示。
{
"editor.inlayHints.enabled": "offUnlessPressed"
}
谢谢你,伙计。