Repository navigation
Fix(vim): Ctrl+[ leaves insert mode where Mod is Ctrl - #1100
Open
2648782102 wants to merge 1 commit into
Open
2648782102 wants to merge 1 commit into
2648782102 wants to merge 1 commit into
Conversation
Author
|
Verification note so nobody has to re-derive it: run the test from the package, The full |
This branch has not been deployed
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
Closes #1059.
This follows the diagnosis and public patch attached to #1059 by @phildubach.
defaultKeymapbindsMod-[toindentLess. On Linux and Windows,Modis Ctrl, so that binding ran beforecodemirror-vimsaw the key.indentLessreports the key as handled even when there is nothing to dedent, soCtrl+[never reached Vim's<C-[>→<Esc>and insert mode stayed active.The fix defers
Mod-[to the Vim plugin in every Vim mode, using the existing Vim-aware wrappers from #993 (Mod-a) and #803 (Escape), and setspreventDefault: falseso the deferred key can fall through to Vim.Behavior
Mod-[behaviorCtrl+[performs<Esc>in insert, normal, and visual modesCmd-[remainsindentLess; this change does not touch itindentLess; no changeMod-]decisionI did not change
Mod-]. Vim's standard mapping set uses<C-[>for Escape, whileCtrl+]has no corresponding action in this editor.Mod-]is bound toindentMore, so deferring it would remove the symmetric indent shortcut without enabling a Vim action. The asymmetry is intentional: only the chord that collides with Vim is deferred.Tab/Shift-Tabremain the Vim-friendly indent path, andMod-]continues to work for indent with Vim on and off.Tests
vimAwareDefaultKeymapbeforevim(), matching the real editor dispatch order.main, the newCtrl+[assertions fail with insert mode still active, confirming the reproduction; with the fix they pass.Ctrl+[ending insert mode in the dispatched chord test.Mod-[deferring in normal and visual modes.Cmd-[still runningindentLesson macOS.Ctrl+[still runningindentLesswith Vim off.Mod-]still runningindentMorewith Vim on.Commands run:
The full app-core suite's 8 failures are unrelated to this change: 7 Harper tests cannot load
node_modules/harper.js/dist/harper_wasm_bg.wasm, and one CloudSettings assertion fails. I reproduced both by running those two files after temporarily removing this change; they fail identically on untouchedmain.There is no separate lint step: CONTRIBUTING.md says so. I checked formatting with the repository's available Prettier, but did not run
--writeacross these files because that reformats the whole file and would obscure this focused patch; the surrounding style is preserved.Attribution
Risk
The change only affects the
Mod-[binding in Vim mode on platforms whereModis Ctrl. A user relying on Ctrl+[ as indent while Vim is enabled would lose that shortcut, but that combination conflicts with Vim's expected Escape behavior;Mod-]and Tab still provide indent controls. No merge performed.