Add support for exporting default keybindings#299026
Draft
Conversation
Contributor
There was a problem hiding this comment.
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
KeybindingsExportContributionthat reads the CLI flag and writes three per-platform keybinding JSON files, then quits - Refactors
KeybindingsRegistryImplto also store rawIKeybindingRuleobjects in a new_coreKeybindingRuleslist, enabling re-resolution of keybindings for any target OS - Adds
getDefaultKeybindingsContentForOS(os)toIKeybindingServiceand implements it inWorkbenchKeybindingServiceusing 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 |
src/vs/workbench/services/keybinding/browser/keybindingService.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
@joaomoreno Could you review this PR to verify if there are no obvious engineering inconsistencies or possible improvements? Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce functionality to export default keybindings for all platforms via a CLI option:
Ref: #299021