Skip to content

Fix emoji and CJK cursor display width#117

Open
ryanoneill wants to merge 1 commit intomainfrom
fix/emoji-cursor-display-width
Open

Fix emoji and CJK cursor display width#117
ryanoneill wants to merge 1 commit intomainfrom
fix/emoji-cursor-display-width

Conversation

@ryanoneill
Copy link
Owner

Summary

  • Add cursor_display_position() to InputFieldState and TextAreaState that returns terminal column width using unicode-width, correctly handling wide characters (emoji, CJK) that occupy 2 terminal columns
  • Update all 6 cursor rendering sites (InputField, TextArea, Form, LogViewer, DataGrid, ChatView) to use display width instead of character count
  • Keeps existing cursor_position() API unchanged (175+ test call sites)

Before: Text "A😀B" with cursor after emoji — cursor_position() returns 2, cursor renders 1 column too far left
After: cursor_display_position() returns 3 (A=1col + 😀=2cols), cursor renders at correct position

Test plan

  • New unit tests for cursor_display_position() on both InputField and TextArea (ASCII, emoji, CJK, mixed, empty, multiline)
  • Doc tests on both new methods showing difference from cursor_position()
  • All existing tests pass (278 tests)
  • cargo clippy --all-targets --all-features -- -D warnings clean

🤖 Generated with Claude Code

Add cursor_display_position() to InputFieldState and TextAreaState that
returns terminal column width using unicode-width, accounting for wide
characters (emoji, CJK) that occupy 2 terminal columns. Update all 6
rendering sites to use display width instead of character count.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.61%. Comparing base (087bee6) to head (d7ce4bb).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #117   +/-   ##
=======================================
  Coverage   92.61%   92.61%           
=======================================
  Files         100      100           
  Lines        9530     9535    +5     
=======================================
+ Hits         8826     8831    +5     
  Misses        704      704           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants