Skip to content

feat(core): Add in functionality for double-click word selection and triple-click line selection#1229

Open
Karvy-Singh wants to merge 9 commits into
anomalyco:mainfrom
Karvy-Singh:main
Open

feat(core): Add in functionality for double-click word selection and triple-click line selection#1229
Karvy-Singh wants to merge 9 commits into
anomalyco:mainfrom
Karvy-Singh:main

Conversation

@Karvy-Singh

@Karvy-Singh Karvy-Singh commented Jul 5, 2026

Copy link
Copy Markdown

Adds multi-click mouse selection support for edit-buffer renderables.
(solves #74 and #744 )

Behavior:

  • Double-click selects the clicked word.
  • Triple-click selects the clicked line.
  • Multi-click detection uses a 500ms threshold (as 200-500ms is considered the common metric).
  • Clicks must be on the same target, same button, and same coordinates to count as a multi-click.
  • Punctuation is treated as a word boundary, so Emacs-style) selects only the clicked word segment, for example Emacs or style.
  • Whitespace clicks do not select surrounding words.
  • Underscores are treated as word characters, so foo_bar is selected as one word.
  • Ctrl-click behavior is unchanged.
  • Normal single-click drag selection behavior is unchanged.

Notes:

  • The implementation is kept close to the existing left mouse down selection branch.
  • Added focused regression tests for double-click word selection, triple-click line selection, punctuation boundaries, first-letter clicks, and whitespace clicks.
  • Other file changes are formatting-only from bun fmt.

(Video below shows the implementation of functionalities as mentioned above)
(Tested against the bun run dev Input->Editor Demo in packages/examples/)

output.mp4

Copilot AI review requested due to automatic review settings July 5, 2026 18:48

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.

Pull request overview

Adds multi-click mouse selection support for edit-buffer-backed renderables (e.g., Textarea) so double-click selects the clicked word and triple-click selects the clicked line, with regression tests covering the new selection behaviors.

Changes:

  • Track consecutive clicks in CliRenderer and intercept double-/triple-clicks for EditBufferRenderable before the normal drag-selection path.
  • Implement word-token and line selection helpers on EditBufferRenderable.
  • Add selection regression tests for double-click word selection and triple-click line selection (plus boundary cases).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/core/src/renderer.ts Adds click-sequence tracking and dispatches edit-buffer multi-click selection actions.
packages/core/src/renderables/EditBufferRenderable.ts Implements selectWordAt / selectLineAt and supporting word-token detection.
packages/core/src/renderables/tests/Textarea.selection.test.ts Adds regression tests for new multi-click selection behaviors and edge cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/renderables/EditBufferRenderable.ts
Comment thread packages/core/src/renderer.ts
Karvy-Singh and others added 2 commits July 6, 2026 00:46
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Karvy-Singh

Copy link
Copy Markdown
Author

Hello @simonklee and @kommander,

Have you had a chance to review the code for the feature ?
Please suggest any changes you see fit and require from my side.

(P.S. Thank you for running the checks earlier, ever since I have only merged the latest change done for updating Node version in my existing PR.)

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.

2 participants