How to filter menu context based on file suffix condition
Trying to create vscode extension to resize image file. I want to right click an image file type in explorer to bring up the extension.
I have the selected item file path from the explorer view, passing the parameter to the vscode.URI
command from the original context. But I have a question regarding how to filter the menu for images only:
How can I only show the context menu item when the file is an image type? Is there a way to specify something like this in the context of an extension?
{
"when": "resourceFilename == CA375AS062_princeton_3750_angle_shader_paint_brush_size_5_8__1000.jpg",
"title": "Resize Image",
"command": "fireshop.resizeImage",
"group": "fireshop-nav"
},
This condition works so that the left side is right, but I only want to define the file suffix like .jpg, .jpeg, .png
etc. Is it possible? (documents on when conditions need improvement!)
source to share
The solution is to use resourceExtname
the extension name to "filter".
{
"command": "fireshop.resizeImage",
"group": "navigation",
"when": "resourceExtname == .jpg"
}
It was released on 10 October with PR 34889
source to share