Open
Conversation
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.
Why
I noticed that pressing dead keys (like "^" on German keyboards) twice in Vim normal mode inserts unwanted text ("^^") instead of executing the intended Vim command (moving to the first non-whitespace character). There's also an existing GitHub issue (#159) reporting similar problems with Russian keyboards layouts.
What changed
src/index.ts: Modified the
inputHandlerin thevimPluginto prevent text insertion in Vim normal mode. Specifically, in theif (vim && !vim.insertMode && !cm.curOp?.isVimOp)block, changed theelseclause from signaling a text input event (allowing insertion) to returningtrue(preventing insertion). This blocks dead key artifacts while preserving insert mode composition.Self-Review: I couldn't test if this interferes with japanese IME (see: #152 (comment)), but I think it should be fine as this should only concern insert mode and there I tested compositions like "^+a" which result in the correct "â".
src/vim.js: Added normalization logic in
vimKeyFromEventto handle repeated dead key compositions. Added a check to reduce repeated characters (e.g., "^^" → "^", "йй" → "й") usingkey.split('').every(c => c === key[0]). This ensures malformed keys are corrected before processingSelf-review: Maybe this needs to be handled differently, as now pressing "й" twice results in moving down one instead of two as expected in #159
No other files were modified.
Test plan
Reproduce the Problem (Before Fix):
Test the Fix:
This is a first draft some testing and discussion might be needed before merging.