Description
This is a TUI-specific issue.
When the prompt contains CJK or other multi-width characters before a pasted preview token like [Pasted ~N lines], submitting the prompt may incorrectly include part of the preview text in the final prompt instead of fully replacing it with the pasted content.
This does not seem to be a general encoding issue. The root cause appears to be that the replacement logic mixes terminal visual-width offsets with JavaScript string indices. For ASCII input this works, but for Chinese, Japanese, Korean, emoji, and other multi-width characters, the replacement range becomes misaligned.
Plugins
No Plugins
OpenCode version
1.2.24
Steps to reproduce
- Type Chinese text or any CJK in the prompt input.
- Paste a multi-line block of text so that OpenCode inserts a preview like
[Pasted ~N lines].
- Submit the prompt.
- Observe that part of the
[Pasted ~N lines] preview text is included in the final submitted prompt instead of being fully replaced by the pasted content.
Screenshot and/or share link
No response
Operating System
Windows11
Terminal
Powershell
Description
This is a TUI-specific issue.
When the prompt contains CJK or other multi-width characters before a pasted preview token like
[Pasted ~N lines], submitting the prompt may incorrectly include part of the preview text in the final prompt instead of fully replacing it with the pasted content.This does not seem to be a general encoding issue. The root cause appears to be that the replacement logic mixes terminal visual-width offsets with JavaScript string indices. For ASCII input this works, but for Chinese, Japanese, Korean, emoji, and other multi-width characters, the replacement range becomes misaligned.
Plugins
No Plugins
OpenCode version
1.2.24
Steps to reproduce
[Pasted ~N lines].[Pasted ~N lines]preview text is included in the final submitted prompt instead of being fully replaced by the pasted content.Screenshot and/or share link
No response
Operating System
Windows11
Terminal
Powershell