Fix selection expansion by retaining focused input selections during global key events (#20205)

pull/14735/head
Luke Parker 2026-04-02 08:43:40 +10:00 committed by GitHub
parent cc30bfc94b
commit fa96cb9c6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -299,7 +299,8 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
useKeyboard((evt) => { useKeyboard((evt) => {
if (!Flag.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) return if (!Flag.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) return
if (!renderer.getSelection()) return const sel = renderer.getSelection()
if (!sel) return
// Windows Terminal-like behavior: // Windows Terminal-like behavior:
// - Ctrl+C copies and dismisses selection // - Ctrl+C copies and dismisses selection
@ -323,6 +324,11 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
return return
} }
const focus = renderer.currentFocusedRenderable
if (focus?.hasSelection() && sel.selectedRenderables.includes(focus)) {
return
}
renderer.clearSelection() renderer.clearSelection()
}) })