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 text containing $ gets corrupted when expanding [Pasted ~N lines] placeholders #33699
Pasting text into the TUI prompt collapses it into a [Pasted ~N lines] placeholder, with the real text stored on the prompt part. When that placeholder is expanded back to the full text, the pasted text is passed as the replacement string to String.prototype.replace. A string replacement interprets $ sequences ($$, $&, $`, $'), so pasted code that contains them comes back altered.
Two flows are affected: copying the prompt back to the clipboard, and opening the prompt in the external editor. The submit path is fine because it uses the range-based expander.
Examples (pasted text on the left, what you get back on the right):
const x = ${a}$$ becomes const x = ${a}$ (the $$ collapses to one $)
echo $&done becomes echo [Pasted ~N lines]done ($& re-inserts the placeholder string into the code)
$` and $' are mangled the same way (they pull in text from around the placeholder)
OpenCode version
dev (1.17.9)
Steps to reproduce
Paste a multi-line block containing $$ or $& (shell or template-literal code, for example) into the prompt so it collapses to [Pasted ~N lines].
Copy the prompt to the clipboard, or open it in the external editor.
The text you get back differs from what you pasted.
Activity
github-actions commentedon Jun 24, 2026
This issue might be a duplicate of existing issues. Please check:
[Pasted ~N lines]placeholder expansion usesString.prototype.replacewith the pasted text as the replacement string, which interprets$sequences and causes text corruption/mangling.github-actions commentedon Aug 24, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.