Command
โบ checkCallback
Command.checkCallback property
Complex callback, overrides the simple callback. Used to โcheckโ whether your command can be performed in the current circumstances. For example, if your command requires the active focused pane to be a MarkdownView, then you should only return true if the condition is satisfied. Returning false or undefined causes the command to be hidden from the command palette.
Signature:
checkCallback?: (checking: boolean) => boolean | void;
Example
this.addCommand({
id: 'example-command',
name: 'Example command',
checkCallback: (checking: boolean) => {
const value = getRequiredValue();
if (value) {
if (!checking) {
doCommand(value);
}
return true;
}
return false;
}
});