I'm developing an extension for VSCode that has a command linked to an item in the context menu. Everything works as expected.
I would like to give the user the additional possibility of hiding or showing that context menu item by acting on a specific option on the settings page.
How do you programmatically hide or delete (and then reappear if necessary) an item in the context menu?
Do you know of an extension that does something like this so I can go and study the code?
I'm asking here because I couldn't find anything explanatory elsewhere.
If you look for real world examples, many extensions are open sourced on GitHub.
Below is an example from my extension.
resttext.table.dataToTable
is registered in package.json
and you can see it is associated with contexts (in when
).editorTextFocus
are provided by VS Code itself.resttext.enter.enabled
. To manipulate them in your extension, use setContext
.