Skip to content

Commit 6c3b28d

Browse files
authored
fix: ensure that double pasting doesnt happen after tui perf commit was merged (#22880)
1 parent 2fe9d94 commit 6c3b28d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • packages/opencode/src/cli/cmd/tui/component/prompt

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,10 @@ export function Prompt(props: PromptProps) {
10311031
return
10321032
}
10331033

1034+
// Once we cross an async boundary below, the terminal may perform its
1035+
// default paste unless we suppress it first and handle insertion ourselves.
1036+
event.preventDefault()
1037+
10341038
const filepath = iife(() => {
10351039
const raw = pastedContent.replace(/^['"]+|['"]+$/g, "")
10361040
if (raw.startsWith("file://")) {
@@ -1048,15 +1052,13 @@ export function Prompt(props: PromptProps) {
10481052
const filename = path.basename(filepath)
10491053
// Handle SVG as raw text content, not as base64 image
10501054
if (mime === "image/svg+xml") {
1051-
event.preventDefault()
10521055
const content = await Filesystem.readText(filepath).catch(() => {})
10531056
if (content) {
10541057
pasteText(content, `[SVG: ${filename ?? "image"}]`)
10551058
return
10561059
}
10571060
}
10581061
if (mime.startsWith("image/") || mime === "application/pdf") {
1059-
event.preventDefault()
10601062
const content = await Filesystem.readArrayBuffer(filepath)
10611063
.then((buffer) => Buffer.from(buffer).toString("base64"))
10621064
.catch(() => {})
@@ -1078,11 +1080,12 @@ export function Prompt(props: PromptProps) {
10781080
(lineCount >= 3 || pastedContent.length > 150) &&
10791081
!sync.data.config.experimental?.disable_paste_summary
10801082
) {
1081-
event.preventDefault()
10821083
pasteText(pastedContent, `[Pasted ~${lineCount} lines]`)
10831084
return
10841085
}
10851086

1087+
input.insertText(normalizedText)
1088+
10861089
// Force layout update and render for the pasted content
10871090
setTimeout(() => {
10881091
// setTimeout is a workaround and needs to be addressed properly

0 commit comments

Comments
 (0)