0

We would like to contribute to the VS Code GitHub and would like to add function to some commands. However, we could not find where the commands are defined. Could anyone tell me which dir these code are in?

We tried the keybinding and workbench. But we cannot find the definition of "ctrl + p" (command palette) which we would like to edit.

1
  • 1
    the commands are defined in the package.json files of the extensions, and some are hardcoded by VSC by calling the command create methods. If you want to add some commands create an extension. In the extension you can call any existing command and thus decorate/use any command. Commented Nov 18, 2023 at 23:15

1 Answer 1

0

For builtin VS Code commands, you want to implement Action2 and then pass your implementation to a call to registerAction2- both of which are defined in the file microsoft/vscode/src/vs/platform/actions/common/actions.ts. registerAction2- among other things- makes the necessary calls to CommandsRegistry.registerCommand, MenuRegistry.appendMenuItem (which makes the command available from the command palette), and KeybindingsRegistry.registerKeybindingRule).

Note that if you don't insist on making the command one builtin to VS Code, you can just do it through an extension by contributing a command in the extension manifest (contributes.commands) and then registering an implementation of the command (see vscode.commands.registerCommand). You can find VS Code's handler for command contributions in its call to commandsExtensionPoint.setHandler in src/vs/workbench/services/actions/common/menusExtensionPoint.ts, which you'll notice makes a call to MenuRegistry.addCommand so the command is accessible from the command palette.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.