Skip to content

Commit fa96cb9

Browse files
authored
Fix selection expansion by retaining focused input selections during global key events (#20205)
1 parent cc30bfc commit fa96cb9

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

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

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
299299

300300
useKeyboard((evt) => {
301301
if (!Flag.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) return
302-
if (!renderer.getSelection()) return
302+
const sel = renderer.getSelection()
303+
if (!sel) return
303304

304305
// Windows Terminal-like behavior:
305306
// - Ctrl+C copies and dismisses selection
@@ -323,6 +324,11 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
323324
return
324325
}
325326

327+
const focus = renderer.currentFocusedRenderable
328+
if (focus?.hasSelection() && sel.selectedRenderables.includes(focus)) {
329+
return
330+
}
331+
326332
renderer.clearSelection()
327333
})
328334

0 commit comments

Comments
 (0)