opencode
opencode copied to clipboard
feat: add input_copy and input_cut keybindings for keyboard-based text selection
Summary
Adds support for copying and cutting selected text in the OpenCode TUI input field using keyboard shortcuts, enabling fully keyboard-centric clipboard workflows.
Fixes #7516
Changes
- Add
input_copykeybinding (default:Ctrl+Insert) - Add
input_cutkeybinding (default:Shift+Delete) - Implement event handlers in prompt component using existing
ClipboardAPI - Works with text selected via
Shift+Arrowand other keyboard selection methods
Default Keybindings
The feature uses CUA-standard (Common User Access) keybindings:
-
Ctrl+Insertfor copy -
Shift+Deletefor cut
Why CUA-standard?
- ✅ Universal compatibility: Works across all terminal emulators (not intercepted like
Ctrl+Shift+C/V) - ✅ Industry standard: From IBM/Windows/Office, familiar to many users
- ✅ Consistent: Aligns with existing
input_pastedefault (Shift+Insert) - ✅ No conflicts: Avoids terminal native shortcuts
Users can customize these via config if desired.
Implementation Details
- Uses
TextareaRenderable.hasSelection()to detect active selections - Uses
TextareaRenderable.getSelectedText()to retrieve selected text - Uses
TextareaRenderable.deleteChar()for cut operation (deletes selection) - Graceful error handling with console logging
- Follows established patterns from
input_pasteandinput_clear
Testing
- ✅ Type checking passes (all packages)
- ✅ All tests pass (622/622)
- ✅ Manual testing: Copy and cut operations work correctly
- ✅ Edge case: No-op when no text is selected (graceful handling)
Related
- Issue: #7516
- Branch:
flexiondotorg:input_copy - Base:
anomalyco:dev