I’m following this tree-view example: https://github.com/microsoft/vscode-extension-samples/blob/main/tree-view-sample/USAGE.md
"contributes": {
"commands": [
{
"command": "nodeDependencies.refreshEntry",
"title": "Refresh",
"icon": {
"light": "resources/light/refresh.svg",
"dark": "resources/dark/refresh.svg"
}
}
],
"menus": {
"view/title": [
{
"command": "nodeDependencies.refreshEntry",
"when": "view == nodeDependencies",
"group": "navigation"
}
]
}
}
I would like to add an extra condition to the when clause (when": "view == nodeDependencies"
). For example, only show the fresh button if the file is a file with name ending in “.xs.ts”. I’m using resourceFilename
and regex pattern to set such condition:
"contributes": {
"commands": [
{
"command": "nodeDependencies.refreshEntry",
"title": "Refresh",
"icon": {
"light": "resources/light/refresh.svg",
"dark": "resources/dark/refresh.svg"
}
}
],
"menus": {
"view/title": [
{
"command": "nodeDependencies.refreshEntry",
"when": "view == nodeDependencies && resourceFilename =~ /.*\.xs\.ts/",
"group": "navigation"
}
]
}
}
Although, a similar condition works for view/item/context
and editor/title
, it doesn’t work for view/title
. If I add another clause besides the one checking the view’ name (view == nodeDependencies
) the refresh button doesn’t show up.