fix(tui): correct IME cursor placement#714
Conversation
🦋 Changeset detectedLatest commit: 4de495d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4de495dd95
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const wrapped = wrapWithSideBorders(lines, (s) => this.borderColor(s), { | ||
| connectedAbove: this.connectedAbove && !this.borderHighlighted, | ||
| }); | ||
| return wrapped.map(removeFakeCursorAtHardwareMarker); |
There was a problem hiding this comment.
Strip the fake cursor before slash highlighting
When the editor text starts with a slash command and the cursor is at the end of the command token (for example after typing / or /help), highlightFirstSlashToken runs before this post-processing and treats CURSOR_MARKER as part of the token, inserting its SGR reset between the marker and pi-tui's \u001B[7m fake cursor. removeFakeCursorAtHardwareMarker then no-ops because the marker is no longer immediately followed by \u001B[7m, so the inverse fake cursor remains exactly in the slash-command path where hardware cursor mode should remove it. Move the fake-cursor stripping before slash highlighting or make the highlighter ignore the marker.
Useful? React with 👍 / 👎.
Related Issue
Resolve #712
Problem
See linked issue. In WezTerm and Alacritty, Chinese IME candidate windows were not anchored to the editor cursor. Enabling the hardware cursor fixed candidate placement, but also exposed a double cursor in the main terminal editor.
What changed
Enabled the TUI hardware cursor so terminal IME candidate windows can follow the editor cursor. The main editor now removes the rendered fake cursor when the hardware cursor marker is present, avoiding the double-width cursor while preserving IME positioning.
Added regression coverage for hardware cursor initialization and editor cursor rendering.
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.