Skip to content

Fix cursor skipping through emoji and special characters#140

Merged
shellicar merged 1 commit intomainfrom
fix/cursor-grapheme-clusters
Mar 28, 2026
Merged

Fix cursor skipping through emoji and special characters#140
shellicar merged 1 commit intomainfrom
fix/cursor-grapheme-clusters

Conversation

@shellicar
Copy link
Copy Markdown
Owner

Summary

  • Cursor moves by visible character, not internal code position
  • Arrow keys correctly cross emoji and multi-part characters in a single keypress

Closes #138

@shellicar shellicar added this to the 1.0 milestone Mar 28, 2026
@shellicar shellicar added the bug Something isn't working label Mar 28, 2026
@shellicar shellicar self-assigned this Mar 28, 2026
@shellicar shellicar enabled auto-merge (squash) March 28, 2026 10:53
Copy link
Copy Markdown
Collaborator

@bananabot9000 bananabot9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Grapheme-cluster navigation via Intl.Segmenter in moveLeft/moveRight, plus the cursorCol fix in renderer.ts (now stringWidth on both sides instead of mixing visible width with code unit offset).

Minor note: deleteBackward may also need grapheme-aware deletion -- pressing backspace on an emoji might only delete one surrogate. Worth a quick test, but not a blocker for this PR.

@shellicar shellicar merged commit 5598f8d into main Mar 28, 2026
4 checks passed
@shellicar shellicar deleted the fix/cursor-grapheme-clusters branch March 28, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cursor navigation skips inside emoji and multi-codepoint characters

2 participants