Remove context option

I need to remove this rename option provided in context menu from explorer view


How to remove or disable this rename option .

If there are any examples please provide it.

@LOGAN thank you for the discussion :+1:

The Rename context-menu item for the Explorer/Navigator is contributed like so:

You can use the MenuModelRegistry to unregister the menu with unregisterMenuAction which accepts a command and path:

this.registry.unregisterMenuAction(WorkspaceCommands.FILE_RENAME, NavigatorContextMenu.MODIFICATION);

I am able to remove the option

Thank you for the response.

1 Like

The solution removed rename option globally.

Is it possible to remove rename option only on the files in explorer view.

Rename option should be not be made available for the files

Files should not be renamed but folders can be renamed

@LOGAN the current implementation of the FILE_RENAME works for both files and folders. If you want to remove the context-menu for files then un-register the command but re-register it for folders only. You can use what is known as when-clause-contexts to do so:

registry.unregisterMenuAction(WorkspaceCommands.FILE_RENAME, NavigatorContextMenu.MODIFICATION);
registry.registerMenuAction(NavigatorContextMenu.MODIFICATION, {
    when: 'explorerResourceIsFolder'

I am able to remove the options
Thank you