GeezerVison is showing github.com — CJK characters break some features like `@` mentions · Issue #3734 · anomalyco/opencode
CJK characters break some features like @ mentions #3734Labels bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentui Activitychanged the title [-]CJK characters break features like `@` mentions[/-] [+]CJK characters break some features like `@` mentions[/+] on Nov 2, 2025github-actions commented on Nov 2, 2025 This issue might be a duplicate of existing issues. Please check:
All of these issues seem to stem from similar underlying problems with Unicode/CJK character handling in the TUI components. The root cause appears to be inconsistent character width calculation between Unicode codepoints and display width, which is exactly what you've identified in the autocomplete.tsx file.
Feel free to ignore if none of these address your specific case with @ mention autocomplete functionality. yukukotani commented on Nov 2, 2025 ContributorAuthor More actions @kommander FYI since I assume you are working on this yukukotani commented on Nov 2, 2025 ContributorAuthor More actions I can take this on if I get a bit of guidance on the right approach. kommander commented on Nov 2, 2025 That is a tricky one. The 3 is in "number of utf16 characters", while the 5 is in "in number of terminal cells", so visualCursor.offset is actually number of cells. Currently the underlying EditBuffer in zig uses "number of cells occupied" as main coordinate system for the cursor. Which is bad.
However, there are methods to convert to a byte offset. So I think opentui needs to expose some methods to work with the Editbuffer properly.
String.at is not grapheme aware, it coincidentally works in this specific case, but for combining characters like acutes or devanagari viramas it would treat the combining chars as separate chars.
For example 世 is U+4E16 in three utf8 bytes.
Edit: I'll follow up on this. kommander commented on Nov 3, 2025 I think the simplest solution to make this work properly, without going into the huge refactor that is needed for the text handling in opentui, is exposing a getTextRange method for the TextBuffer in opentui, so opencode can use that instead of String.at. Then charBeforeCursor would be something like input.getTextRange(cursor.offset - 1, cursor.offset). I'll check how hard it would be to implement that. Would at least make it reliable for now, no matter how opentui treats text internally. kommander commented on Nov 3, 2025 This should be mitigated in 1.0.16 yukukotani commented on Nov 3, 2025 ContributorAuthor More actions kommander commented on Nov 13, 2025 Should be better in the latest version? zenyr commented on Nov 27, 2025 Update as of v1.0.117
-
The original issue seems mostly fixed ~2 weeks ago
👇 Working fine now 👍

-
However [Pasted] is a bit broken AFTER submitting
👇 CJK/Emojis breaking [Pasted] marker 🥲 (Before & after)

안녕 {cmd+v} 하세요
Reacted by Koichi Nakayamada and oujionghong
MetadataMetadatabugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentui DevelopmentNo branches or pull requestsIssue actions
|