Skip to content

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

Closed

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

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Mar 11, 2026
  2. github-actions commented on Mar 11, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

    If this is a distinct root cause (visual-width vs. string-index mismatch specific to multi-width characters), feel free to clarify that so maintainers can keep both open if needed.

  3. AbigailJixiangyuyu commented on Mar 11, 2026

    @AbigailJixiangyuyu
    ContributorAuthor

    This issue might be a duplicate of an existing issue. Please check:

    If this is a distinct root cause (visual-width vs. string-index mismatch specific to multi-width characters), feel free to clarify that so maintainers can keep both open if needed.

    No, they’re not the same issue.

  4. removed
    bugSomething isn't working
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on May 3, 2026
  5. zclllyybb commented on May 5, 2026

    @zclllyybb

    @AbigailJixiangyuyu Hi, I have fixed it in #25855. maybe you can test this patch. it works well for me.

  6. simonklee commented on Jun 1, 2026

    @simonklee
    Member
  7. AbigailJixiangyuyu commented on Jun 1, 2026

    @AbigailJixiangyuyu
    ContributorAuthor

    bba7600

    Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions