Skip to content

fix(terminal): restore Ctrl+Shift+C copy and copy on Ctrl+C with selection on Windows - #1978

Merged
Hona merged 1 commit into
devfrom
fix/terminal-windows-copy-shortcut
Dec 1, 2026
Merged

Hona merged 1 commit into
devfrom
fix/terminal-windows-copy-shortcut

Conversation

@Hona

@Hona Hona commented Dec 1, 2026

Copy link
Copy Markdown
Member

Fixes #1970

Problem

On Windows (and Linux), pressing Ctrl+Shift+C in the built-in terminal did nothing, and pressing Ctrl+C after selecting text cleared the selection and sent SIGINT instead of copying:

  1. Ctrl+Shift+C was intercepted before Bind::TerminalCopy: side_ops::key_terminal checked host.plugin_takes_chord(ev, tx) before calling input::dispatch_key. plugins/browser/init.luau registered browser.inspect (mod+shift+c, which resolves to Ctrl+Shift+C on Windows/Linux) and other pane-scoped commands without an enabled guard. takes_chord therefore yielded Ctrl+Shift+C out of the terminal even when no browser tab was focused or open; browser.inspect then declined because Browser:Focused() was nil, silently dropping the shortcut.
  2. Ctrl+C with a selection on Windows did not copy: input::dispatch_key only matched Bind::TerminalCopy (super+c, ctrl+shift+c), so Ctrl+C (and the Windows app menu's Edit > Copy) always forwarded ^C to the PTY even with text selected.

Changes

  • plugins/browser/init.luau & apps/desktop/src/plugin_host/native/browser.rs: Add enabled = function() return Browser:Focused() ~= nil end to pane-scoped browser commands (matching official packages/gui-plugins/src/browser/renderer.tsx scope: "#browser-panel") and hash editors::plugin_focused(app, "browser") in Dep::Browser.
  • apps/desktop/src/plugin_host/bridge/commands.rs: Skip dormant browser pane-scoped commands (those with a recorded enabled function) in takes_chord, respect Settings › Shortcuts overrides (overrides::command), and continue to subsequent matching plugin commands if an earlier command declines.
  • features/terminal-surface/src/side_ops.rs & features/terminal-surface/src/input.rs: Check plugin_takes_chord alongside takes_from_pane inside dispatch_key (after terminal-owned bindings such as TerminalCopy, TerminalPaste, and Find); consume Ctrl+Shift+C without sending SIGINT when nothing is selected (matching official terminal.tsx:477); and on Windows copy + clear selection on Ctrl+C when text is selected while preserving Ctrl+C SIGINT when nothing is selected.
  • crates/opencode-ui/src/keymap/mod.rs: Order ctrl+shift+c before super+c on Windows and Linux for Bind::TerminalCopy, matching Bind::TerminalPaste.

Verification

  • Passed pwsh scripts/guardrails.ps1 (11/11).
  • Passed cargo check -p opencode-ui -p opencode-feature-terminal-surface -p opencode-desktop --lib --bins.
  • Passed cargo clippy -p opencode-ui -p opencode-feature-terminal-surface -p opencode-desktop --lib --bins --no-deps with zero diagnostics in modified lines.
  • Not verified locally: Interactive Windows GUI terminal copy/SIGINT and macOS/Linux runtime builds (delegated to CI and live verification).

…ction on Windows (#1970)

- Scope browser pane commands in plugins/browser/init.luau with enabled = function() return Browser:Focused() ~= nil end (matching packages/gui-plugins/src/browser/renderer.tsx scope: "#browser-panel"), include browser editor focus in Dep::Browser, and skip dormant browser pane-scoped commands in plugin_host::commands::takes_chord so browser.inspect (mod+shift+c) does not intercept Ctrl+Shift+C in the terminal on Windows and Linux.
- Evaluate plugin_takes_chord alongside takes_from_pane inside terminal_surface::input::dispatch_key (after terminal-owned bindings such as TerminalCopy, TerminalPaste, and Find) and consume Ctrl+Shift+C with no selection instead of forwarding SIGINT.
- On Windows, copy and clear the active terminal selection on Ctrl+C (matching Windows Terminal, VS Code, and Edit > Copy), while preserving Ctrl+C SIGINT when nothing is selected.
- List ctrl+shift+c first on Windows and Linux for Bind::TerminalCopy (matching Bind::TerminalPaste).
Copilot AI balanced review requested due to automatic review settings December 1, 2026 08:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Hona
Hona merged commit 9d6a004 into dev Dec 1, 2026
3 checks passed
@Hona
Hona deleted the fix/terminal-windows-copy-shortcut branch December 1, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Terminal] windows 端终端无法使用快捷键复制

2 participants