Skip to content

Support shift+click to extend selection (#23)#27

Merged
Wavesonics merged 3 commits into
mainfrom
fix/issue-23-shift-click
Jun 12, 2026
Merged

Support shift+click to extend selection (#23)#27
Wavesonics merged 3 commits into
mainfrom
fix/issue-23-shift-click

Conversation

@Wavesonics

Copy link
Copy Markdown
Owner

Summary

Shift+click now extends the selection from the existing cursor/anchor to the clicked position, instead of clearing it.

Root cause

The mouse pointer handling never checked isShiftPressed, and three parallel pointerInput handlers each cleared/restarted the selection on a primary press. There was no shift-click-to-extend path, and the parallel handlers racing to clear the selection caused the intermittent failures users saw.

Fix

  • New shared TextEditorSelectionManager.extendSelection(anchor, newPosition) that holds the far anchor fixed and returns it — unifying the logic used by shift+arrow and shift+click.
  • handleDragInput owns shift+click extension (extends from the cursor / far anchor to the click, moves the cursor to the click).
  • The other two handlers (detectMouseClicksImperatively onClick, handleTextInteractions/handleSpanInteraction) leave the selection untouched while Shift is held, removing the race.

Tests

  • New ShiftClickExtendSelectionTest (selection-extension logic, headless).
  • Verified live in the running sample app via the hot-reload MCP (shift+click selects consistently across repeated clicks).
  • Full ./gradlew check passes locally.

Fixes #23

Wavesonics and others added 3 commits June 12, 2026 00:16
Shift+click now extends the selection from the cursor (or the existing
selection's far anchor) to the clicked position instead of clearing it. A
shared extendSelection() unifies the logic with shift+arrow, and the parallel
click handlers leave the selection alone while shift is held, fixing the
intermittent failure caused by them racing to clear the extension.

Fixes #23

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Gate the shift+click cursor move with !readOnly so mouse-driven shift+click
matches plain-click and drag behavior; selection still extends in readOnly.

Add a Compose UI test that drives the real pointer-input handlers with a
held Shift modifier, guarding the parallel-handler race that the existing
selection-math test cannot reach.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Wavesonics Wavesonics marked this pull request as ready for review June 12, 2026 07:56
@Wavesonics Wavesonics merged commit b073268 into main Jun 12, 2026
1 check passed
@Wavesonics Wavesonics deleted the fix/issue-23-shift-click branch June 12, 2026 07:56
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.

Shift+click does not reliably extend the selection

1 participant