如何在扩展中使用VSCode产品图标执行命令



我正在尝试向运行我的命令的"editor/title"部分添加一个按钮。在我当前的配置中,当单击3个按钮展开菜单时,我的命令名会出现。我想要的是显示一个图标(比如分割编辑器按钮(,它运行我的命令。

从文档中,我发现应该可以为图标提供svg文件,但我更喜欢使用产品图标中的图标。通过这种方式,图标可以随主题而变化。

这可能吗,还是我只是配置不正确?

这是我到目前为止的配置:

"contributes": {
"commands": [
{
"command": "my-extension.my-command"
"title": "My Command",
"icon": "preview" // <-- this refers to the icon from 'product icons'
}
],
"menus": {
"editor/title": [
{
"when": "resourceExtname == .xyz",
"command": "my-extension.my-command"
}
]
}
}

这应该有效:

"contributes": {
"commands": [
{
"command": "my-extension.my-command"
"title": "My Command",
"icon": "$(preview)" // <-- the syntax for using a 'product icon' is $(iconIdentifier)
}
],
}

相关内容

最新更新