mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-14 03:56:55 +03:00
fix(tui): copy the paste inside the prompt selection (#63275)
This commit is contained in:
committed by
GitHub
Unverified
parent
32a00c976d
commit
28f74f8591
@@ -1822,7 +1822,18 @@ export function Prompt(props: PromptProps) {
|
||||
ref={(r: TextareaRenderable) => {
|
||||
input = r
|
||||
Object.assign(r, {
|
||||
getClipboardText: (text: string) => expandPastedTextPlaceholders(text, store.prompt.pasted),
|
||||
getClipboardText: (text: string) => {
|
||||
const range = r.getSelection()
|
||||
// A selection spanning other renderables is not indexed relative to this textarea.
|
||||
if (!range || text !== r.getSelectedText()) {
|
||||
return expandPastedTextPlaceholders(text, store.prompt.pasted)
|
||||
}
|
||||
const parts = store.prompt.pasted.flatMap(({ source, text }) => {
|
||||
if (source.start < range.start || source.end > range.end) return []
|
||||
return [{ start: source.start - range.start, end: source.end - range.start, text }]
|
||||
})
|
||||
return expandTrackedPastedText(text, parts, renderer.widthMethod)
|
||||
},
|
||||
})
|
||||
setInputTarget(r)
|
||||
if (promptPartTypeId === 0) {
|
||||
|
||||
Reference in New Issue
Block a user