Skip to content

Add support for exporting default keybindings#299026

Draft
ntrogh wants to merge 3 commits intomainfrom
ntrogh/export-keybindings
Draft

Add support for exporting default keybindings#299026
ntrogh wants to merge 3 commits intomainfrom
ntrogh/export-keybindings

Conversation

@ntrogh
Copy link
Contributor

@ntrogh ntrogh commented Mar 3, 2026

Introduce functionality to export default keybindings for all platforms via a CLI option:

code --export-default-keybindings <output folder>

Ref: #299021

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a command-line option (--export-default-keybindings) to export default keybindings for all three platforms (Windows, macOS, Linux) as JSON files. This is needed to generate documentation reference files that map command IDs to their default keyboard shortcuts.

Changes:

  • Adds a new KeybindingsExportContribution that reads the CLI flag and writes three per-platform keybinding JSON files, then quits
  • Refactors KeybindingsRegistryImpl to also store raw IKeybindingRule objects in a new _coreKeybindingRules list, enabling re-resolution of keybindings for any target OS
  • Adds getDefaultKeybindingsContentForOS(os) to IKeybindingService and implements it in WorkbenchKeybindingService using per-OS keyboard mappers built from the exported EN-US layout constants

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/vs/workbench/workbench.desktop.main.ts Registers the new keybindingsExport contribution for desktop builds
src/vs/workbench/contrib/keybindingsExport/electron-browser/keybindingsExport.contribution.ts New contribution: reads --export-default-keybindings CLI flag, writes platform-specific JSON files, then calls nativeHostService.exit
src/vs/workbench/services/keybinding/browser/keybindingService.ts Adds getDefaultKeybindingsContentForOS, _createKeyboardMapperForOS, and _resolveKeybindingItemsWithMapper static helpers
src/vs/workbench/services/keybinding/browser/keyboardLayouts/en.win.ts Exports EN_US_WIN_LAYOUT constant so it can be imported by the keybinding service
src/vs/workbench/services/keybinding/browser/keyboardLayouts/en.linux.ts Exports EN_US_LINUX_LAYOUT constant
src/vs/workbench/services/keybinding/browser/keyboardLayouts/en.darwin.ts Exports EN_US_DARWIN_LAYOUT constant
src/vs/platform/keybinding/common/keybindingsRegistry.ts Adds _coreKeybindingRules list to store raw rules; adds getDefaultKeybindingsForOS; refactors bindToCurrentPlatform to delegate to new bindToPlatform(kb, os)
src/vs/platform/keybinding/common/keybinding.ts Adds getDefaultKeybindingsContentForOS(os) to IKeybindingService interface
src/vs/platform/keybinding/common/abstractKeybindingService.ts Provides default no-op getDefaultKeybindingsContentForOS implementation
src/vs/platform/keybinding/test/common/mockKeybindingService.ts Adds stub getDefaultKeybindingsContentForOS to the mock
src/vs/platform/environment/common/environment.ts Adds exportDefaultKeybindings?: string to INativeEnvironmentService
src/vs/platform/environment/common/environmentService.ts Implements exportDefaultKeybindings getter
src/vs/platform/environment/common/argv.ts Adds 'export-default-keybindings'?: string to NativeParsedArgs
src/vs/platform/environment/node/argv.ts Registers the --export-default-keybindings option descriptor with allowEmptyValue: true

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ntrogh
Copy link
Contributor Author

ntrogh commented Mar 3, 2026

@joaomoreno Could you review this PR to verify if there are no obvious engineering inconsistencies or possible improvements? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants