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.
For builtin VS Code commands, you want to implement
Action2and then pass your implementation to a call toregisterAction2- 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 toCommandsRegistry.registerCommand,MenuRegistry.appendMenuItem(which makes the command available from the command palette), andKeybindingsRegistry.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 (seevscode.commands.registerCommand). You can find VS Code's handler for command contributions in its call tocommandsExtensionPoint.setHandlerin src/vs/workbench/services/actions/common/menusExtensionPoint.ts, which you'll notice makes a call toMenuRegistry.addCommandso the command is accessible from the command palette.