Skip to content

fix: sync drawSelection cursor when entering vim insert mode#527

Merged
kwannoel merged 1 commit intomainfrom
session-1-600563
Mar 20, 2026
Merged

fix: sync drawSelection cursor when entering vim insert mode#527
kwannoel merged 1 commit intomainfrom
session-1-600563

Conversation

@kwannoel
Copy link
Copy Markdown
Owner

Summary

  • Fixed vim a (append) in notes editor where typed characters appeared visually offset from the cursor
  • Root cause: drawSelection() updates its cursor overlay via requestAnimationFrame, but the cm-vimMode CSS class is removed synchronously when entering insert mode — the overlay briefly shows the stale normal-mode position
  • Fix: call view.measure() via queueMicrotask in the vim-mode-change handler to force synchronous cursor repositioning before the browser paints
  • Added unit tests for vim a and i cursor positioning

Test plan

  • All 296 frontend tests pass
  • Rust tests pass
  • New unit tests verify cursor position after a, i, and entry key flow

🤖 Generated with Claude Code

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>
@kwannoel kwannoel merged commit 5415de9 into main Mar 20, 2026
1 of 3 checks passed
@kwannoel kwannoel deleted the session-1-600563 branch March 20, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant