fix: sync drawSelection cursor when entering vim insert mode#527
Merged
fix: sync drawSelection cursor when entering vim insert mode#527
Conversation
The drawSelection() cursor overlay updates its position via requestAnimationFrame. When pressing `a` in vim normal mode, the cm-vimMode CSS class is removed synchronously (making the overlay visible), but the overlay still sits at the stale normal-mode position until the next frame — causing typed characters to appear visually offset from the cursor. Fix: call view.measure() via queueMicrotask in the vim-mode-change handler so the overlay repositions before the browser paints. Also adds unit tests verifying vim `a` and `i` cursor positioning. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
a(append) in notes editor where typed characters appeared visually offset from the cursordrawSelection()updates its cursor overlay viarequestAnimationFrame, but thecm-vimModeCSS class is removed synchronously when entering insert mode — the overlay briefly shows the stale normal-mode positionview.measure()viaqueueMicrotaskin thevim-mode-changehandler to force synchronous cursor repositioning before the browser paintsaandicursor positioningTest plan
a,i, and entry key flow🤖 Generated with Claude Code