fix(keymap): layer vscode keymap on macos when target is macOS (#1916)#1998
Open
sinelaw wants to merge 1 commit into
Open
fix(keymap): layer vscode keymap on macos when target is macOS (#1916)#1998sinelaw wants to merge 1 commit into
sinelaw wants to merge 1 commit into
Conversation
The `vscode` keybinding map only adds 4 ctrl-based overrides on top of the shared `default` keymap. On every platform that delivers `default`'s Linux/Windows-VSCode conventions — most visibly Alt+Right -> navigate_forward, which on macOS (Option+Right) should be word-end movement per VSCode's Mac conventions. Issue #1916. `load_builtin_keymap` is extracted into a helper that takes an explicit `is_macos` flag so the platform-conditional rewrite ("vscode" inherits "macos" on macOS) is testable from any host. Production callers continue to use `cfg!(target_os = "macos")`. Adds four regression tests covering: - vscode keymap inherits "macos" on macOS / "default" elsewhere - Resolved Option+Right (mac target) -> move_word_end - Resolved Alt+Right (non-mac target) -> navigate_forward (no regression) https://claude.ai/code/session_01S7vceisnAN96RWdKPFdTGt
Owner
Author
|
Maybe we should just udpate the macos keyboard map directly without needing the vscode map at all in this case? i.e. for the specific keys the user complained about, update macos map |
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.
Summary
Fixes #1916. The
vscodebuilt-in keymap only adds 4 Ctrl-based overrides on top of the shareddefaultkeymap, so on every platform users get the Linux/Windows VSCode conventions. The most visible breakage on macOS:Alt+Right(Option+Right) →navigate_forwardinstead ofmove_word_endAlt+Left(Option+Left) →navigate_backinstead ofmove_word_leftCtrl+B→ unbound (default uses different mapping) instead oftoggle_file_explorerThe maintainer's fix sketch in the issue suggests making
vscodeinheritmacoson macOS — that's what this PR does. The macOS-specific bindings forAlt+Left/Right,Ctrl+B, etc. already live inmacos.json; layeringvscodeon top means Mac users get Mac VSCode conventions, while the 4 Ctrl-based vscode overrides still win where they apply.Implementation
load_builtin_keymapis split into a thin wrapper plusload_builtin_keymap_for_target(name, is_macos)so the platform-conditional rewrite ("vscode"'sinheritsbecomes"macos"whenis_macosis true) is testable from any host. Production callers continue to usecfg!(target_os = "macos").Test plan
Four new unit tests in
config::tests:test_vscode_keymap_inherits_macos_on_macos— direct check on the loaded keymaptest_vscode_keymap_inherits_default_on_non_macos— non-regression on Linux/Windowstest_vscode_keymap_on_macos_resolves_option_right_to_word_end— end-to-end resolution throughresolve_keymap, confirmsOption+Rightlands onmove_word_endtest_vscode_keymap_on_non_macos_resolves_alt_right_to_navigate_forward— end-to-end resolution preservesAlt+Right → navigate_forwardon non-macOSVerified the macOS-target tests fail before the fix (
Got: Some("navigate_forward")vs expectedSome("move_word_end")) and pass after — satisfies CONTRIBUTING.md's "fails without fix, passes with fix" requirement.Also ran:
cargo fmt --checkcargo clippy -p fresh-editor --lib --tests --no-deps(no new warnings introduced)cargo check -p fresh-editor --all-targets --features gui(GUI feature builds)config::tests::andinput::keybindings::test modulestarget/release/freshin tmux withactive_keybinding_map: vscode— editor starts cleanly, Alt+Right is unchanged on Linux as expectedScope notes
This only addresses the terminal/Option+Left/Right half of #1916. The
Cmd+Bhalf is acknowledged in the issue as overlapping with the long-known macOS-terminal Cmd-key delivery problem (#356, #219) — a vscode user onfresh-guiwho wants Cmd shortcuts can still pickmacos-guidirectly; if a future PR wants vscode-on-GUI to inheritmacos-gui, the GUI auto-select ingui/mod.rscan be extended.https://claude.ai/code/session_01S7vceisnAN96RWdKPFdTGt
Generated by Claude Code