monaco-editor
monaco-editor copied to clipboard
Remove unused commands from the all command list
The monaco editor lists all available commands in the Commands list, and doesn't take into account enabled features. ie: if I disable folding in the editor config It still shows all the Folding commands: Fold All, Unfold All, etc.
Yup, just hit this. It's weird as the command is still disabled, so nothing happens. But the user would be confused.
Feels like an initialization thing, where when the feature is enabled, that's where the commands should be added to the list or not.
+1
+1
Is there any workaround available? For example disabling (unused) commands manually.
+1
+1
You can manually hide commands from the command palette with the following:
import { StandaloneCommandsQuickAccessProvider } from 'monaco-editor/esm/vs/editor/standalone/browser/quickAccess/standaloneCommandsQuickAccess.js';
const hideCommandIds = [];
const originalFunc = StandaloneCommandsQuickAccessProvider.prototype.getCommandPicks;
StandaloneCommandsQuickAccessProvider.prototype.getCommandPicks = function () {
const filteredCommands = new Promise((resolve) => {
const allCommandsPromise = originalFunc.call(this);
allCommandsPromise.then((commands) => {
resolve(commands.filter((command) => !hideCommandIds.includes(command.commandId)));
});
});
return filteredCommands;
};
Just add the command id of the option you want to hide to hideCommandIds
. For instance, hideCommandIds = ['editor.fold', 'editor.foldAll']
will hide these two options: