monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

Remove unused commands from the all command list

Open samelhusseini opened this issue 8 years ago • 6 comments

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.

samelhusseini avatar Aug 30 '16 18:08 samelhusseini

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.

hawkerm avatar Aug 20 '17 23:08 hawkerm

+1

Canna71 avatar Sep 15 '18 10:09 Canna71

+1

Is there any workaround available? For example disabling (unused) commands manually.

HKalbasi avatar Sep 28 '21 21:09 HKalbasi

+1

rewoop avatar Oct 11 '21 14:10 rewoop

+1

chuckWu1989 avatar Dec 05 '22 09:12 chuckWu1989

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: image

ethan-vanderheijden avatar Feb 10 '24 18:02 ethan-vanderheijden