Skip to content

fix(cli): sync terminal cursor with input caret for CJK IME - #1142

Open
ddddajie wants to merge 1 commit into
CodebuffAI:mainfrom
ddddajie:fix/1128-ime-cursor-position
Open

fix(cli): sync terminal cursor with input caret for CJK IME#1142
ddddajie wants to merge 1 commit into
CodebuffAI:mainfrom
ddddajie:fix/1128-ime-cursor-position

Conversation

@ddddajie

Copy link
Copy Markdown

Summary

Fixes #1128.

The CLI rendered a visual caret but did not move the real terminal hardware cursor to the input position. CJK IMEs use the terminal cursor position to anchor their composition and candidate windows, which caused the popup to appear at unrelated screen locations.

This change:

  • synchronizes the real terminal cursor with the MultilineInput caret
  • accounts for CJK terminal-cell width using string-width
  • handles tabs, wrapped lines, viewport offsets, and vertical scrolling
  • hides the hardware cursor when the input loses focus or unmounts
  • keeps the existing visual cursor behavior unchanged

Tests

Added regression coverage for:

  • ASCII cursor positioning
  • CJK wide characters
  • mixed ASCII/CJK input
  • tab expansion
  • wrapped visual lines
  • viewport and vertical scroll offsets
  • cursor visibility on focus/unmount
  • component-level OpenTUI renderer cursor positioning after a CJK character

Validation:

  • bun test cli/src/components/__tests__/multiline-input.test.tsx — 80 passed
  • repeated test run (--rerun-each 3) — 240 passed
  • git diff --check — passed

The full CLI test command is currently blocked by the pre-existing missing preload ../test/setup-scm-loader.ts.

CLI typecheck is currently blocked by pre-existing missing tar and react-dom/server typings; no errors were reported in the changed files.

Manual Windows Terminal / CJK IME verification was not completed.

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.

CJK IME candidate window anchors to wherever text last changed on screen, not to the input caret — real terminal cursor is never moved

1 participant