Skip to content

Conversation

@ndraiman
Copy link
Contributor

Summary

Double-click on a word to copy it to clipboard, using the same selection mechanism as drag-to-copy.

Changes

  • Detect double-clicks by tracking click time/position (400ms threshold)
  • Find word boundaries by scanning the render buffer for word characters
  • Create selection using existing startSelection/updateSelection APIs
  • Existing onMouseUp handler automatically copies to clipboard with toast notification

Behavior

  • Works anywhere drag-to-copy selection works
  • Word characters: letters, digits, underscore, hyphen (unicode-aware)
  • Respects OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT flag
Screen.Recording.2025-12-28.at.10.39.20.mov

Implement double-click detection and word boundary finding in the terminal UI to enable selecting entire words with a double-click gesture. This feature respects the experimental flag for copy-on-select functionality and integrates with the existing selection APIs.

The implementation includes:
- Double-click detection based on timing and position thresholds
- Word boundary detection using character code analysis
- Integration with renderer's startSelection and updateSelection methods
- Proper state management to prevent triple-clicks being misdetected
Refactored the double-click detection and word selection implementation to be more concise and maintainable. Consolidated multiple state variables into a single click object, inlined helper functions, and simplified the word boundary detection logic while preserving functionality.
The row offset calculation (evt.y * width) was being computed multiple times
in the double-click word selection logic. Extract it to a variable to improve
readability and avoid redundant calculations.
@ndraiman ndraiman force-pushed the ndraiman/double-click-select branch from 99fd358 to 46fd22c Compare December 28, 2025 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.

1 participant