Skip to content

fix: render wide characters (CJK/emoji) at double cell width in terminal#383

Merged
Wirasm merged 2 commits into
mainfrom
kild/315-wide-chars
Feb 11, 2026
Merged

fix: render wide characters (CJK/emoji) at double cell width in terminal#383
Wirasm merged 2 commits into
mainfrom
kild/315-wide-chars

Conversation

@Wirasm

@Wirasm Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Isolate wide characters (CJK, emoji) into individual text runs so each is positioned at its exact grid column, preventing accumulated width errors in mixed-width lines
  • Extend focused cursor to span 2 cell widths when on a wide character
  • Fix pre-existing duplicate imports in health.rs and trailing blank line in create.rs

Closes #315

Test plan

  • Run echo "Hello 你好世界 World" in embedded terminal — CJK chars render at double width, no gaps/overlaps
  • Run echo "Test 🎉🚀 Done" — emoji render at double width, "Done" properly positioned
  • Navigate cursor onto a CJK character — cursor spans 2 cell widths
  • Pure ASCII content — no visual regression
  • cargo test --all passes
  • cargo clippy --all -- -D warnings passes

Break text runs at wide character boundaries so each wide char is
positioned individually at its exact grid column. This prevents width
errors from accumulating across mixed normal/wide character runs.

Also extend the focused cursor to span 2 cell widths when sitting on
a wide character.

Closes #315
@Wirasm

Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner Author

PR Review Summary

Critical Issues (0 found)

None.

Important Issues (0 found)

None.

Suggestions (1 found)

Agent Suggestion Location
comment-analyzer Consider expanding the first comment to explain the text shaping vs. grid positioning mismatch (the "why" behind width errors) terminal_element.rs:388-389

Reviewed & Dismissed

Agent Finding Reason Dismissed
code-reviewer State not reset after wide char continue False positive — the run_text.is_empty() guard at line 444 already resets all run state for the next character

Strengths

  • Clean isolation of wide characters into separate text runs
  • Cursor width properly doubled for wide characters
  • Existing text run batching sentinel pattern handles state resets correctly
  • Minor cleanups (unused imports, trailing blank line) are reasonable housekeeping

Verdict

READY TO MERGE

The wide character rendering fix is correct. Each wide character is isolated into its own BatchedTextRun positioned at its exact grid column, preventing accumulated width errors. The cursor properly spans 2 cells on wide characters. The code integrates cleanly with the existing text run batching state machine.

@Wirasm Wirasm merged commit cd2b6d1 into main Feb 11, 2026
5 of 6 checks passed
@Wirasm Wirasm deleted the kild/315-wide-chars branch February 11, 2026 16:56
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.

kild-ui: wide character (CJK/emoji) rendering in embedded terminals

1 participant