You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Pasted ~N lines] is partially submitted when prompt contains CJK or other multi-width characters #17032
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.
This issue might be a duplicate of an existing issue. Please check:
Paste preview indicator "[Pasted ~N lines]" incorrectly included in submitted input #11143: Same symptom where [Pasted ~N lines] preview text is incorrectly included in the submitted prompt. Your issue provides additional context that CJK/multi-width characters trigger a specific misalignment in the replacement logic, which may or may not be the same underlying bug.
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.
This issue might be a duplicate of an existing issue. Please check:
Paste preview indicator "[Pasted ~N lines]" incorrectly included in submitted input #11143: Same symptom where [Pasted ~N lines] preview text is incorrectly included in the submitted prompt. Your issue provides additional context that CJK/multi-width characters trigger a specific misalignment in the replacement logic, which may or may not be the same underlying bug.
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.
Activity
github-actions commentedon Mar 11, 2026
This issue might be a duplicate of an existing issue. Please check:
[Pasted ~N lines]preview text is incorrectly included in the submitted prompt. Your issue provides additional context that CJK/multi-width characters trigger a specific misalignment in the replacement logic, which may or may not be the same underlying bug.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.
AbigailJixiangyuyu commentedon Mar 11, 2026
No, they’re not the same issue.
zclllyybb commentedon May 5, 2026
@AbigailJixiangyuyu Hi, I have fixed it in #25855. maybe you can test this patch. it works well for me.
simonklee commentedon Jun 1, 2026
bba7600
AbigailJixiangyuyu commentedon Jun 1, 2026
Great!