Skip to content

[Pasted ~N lines] is partially submitted when prompt contains CJK or other multi-width characters #17032

@AbigailJixiangyuyu

Description

@AbigailJixiangyuyu

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.

Image Image

Plugins

No Plugins

OpenCode version

1.2.24

Steps to reproduce

  1. Type Chinese text or any CJK in the prompt input.
  2. Paste a multi-line block of text so that OpenCode inserts a preview like [Pasted ~N lines].
  3. Submit the prompt.
  4. 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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions