Skip to content

fix(editor): restore shift tap selection with native touch selection menu#2013

Merged
bajrangCoder merged 2 commits intoAcode-Foundation:mainfrom
bajrangCoder:fix/shift-touch-selection
Apr 4, 2026
Merged

fix(editor): restore shift tap selection with native touch selection menu#2013
bajrangCoder merged 2 commits intoAcode-Foundation:mainfrom
bajrangCoder:fix/shift-touch-selection

Conversation

@bajrangCoder
Copy link
Copy Markdown
Member

No description provided.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 4, 2026

Greptile Summary

This PR refactors shift-tap text selection on touch devices by moving the logic from a CodeMirror domEventHandlers extension into TouchSelectionMenuController, which captures the selection anchor on pointerdown (document capture phase, before CodeMirror processes the event) and commits the extended range on pointerup. A two-phase handshake via consumePendingShiftSelectionClick then suppresses CM's own click-triggered cursor movement, replacing the fragile pointerIdMap approach with a cleaner, pointer-coordinate-based implementation.

Confidence Score: 5/5

Safe to merge — well-guarded state management, correct capture-phase sequencing, and the two-phase handshake correctly prevents CM from overriding the shift selection on click

No P0 or P1 issues found. Pointer-event capture sequencing is correct (document capture fires before CM view listeners), the anchor is stored before CM processes pointerdown, posAtCoords with precise=false always returns a number, and all state fields are cleaned up in every teardown path (destroy, setEnabled, onSessionChanged). All remaining observations are P2 or lower.

No files require special attention

Important Files Changed

Filename Overview
src/cm/touchSelectionMenu.js Shift-tap selection logic moved into TouchSelectionMenuController using document capture-phase pointerdown/pointerup listeners and a two-phase pending-click handshake; all session state is correctly cleared in destroy, setEnabled, and onSessionChanged
src/lib/editorManager.js Old pointerIdMap-based shiftClickSelectionExtension replaced by isShiftSelectionActive callback passed to TouchSelectionMenuController; click handler now delegates to consumePendingShiftSelectionClick

Sequence Diagram

sequenceDiagram
    actor User
    participant Doc as Document (capture phase)
    participant TSMC as TouchSelectionMenuController
    participant CM as CodeMirror
    participant Browser

    User->>Doc: pointerdown (touch, shift active)
    Doc->>TSMC: onGlobalPointerDown
    TSMC->>TSMC: captureShiftSelection(event)
    Note over TSMC: stores shiftSelectionSession\n{pointerId, anchor, x, y}
    Doc->>CM: pointerdown (bubble phase)
    Note over CM: moves cursor to tapped position

    User->>Doc: pointerup (touch)
    Doc->>TSMC: onGlobalPointerUp
    TSMC->>TSMC: commitShiftSelection(event)
    TSMC->>CM: dispatch EditorSelection.range(anchor, head)
    Note over TSMC: stores pendingShiftSelectionClick
    TSMC->>TSMC: event.preventDefault()
    Doc->>CM: pointerup (bubble phase)

    Browser->>CM: click event
    CM->>TSMC: shiftClickSelectionExtension click handler
    TSMC->>TSMC: consumePendingShiftSelectionClick(event)
    TSMC->>Browser: event.preventDefault()
    TSMC-->>CM: return true (suppress CM click handling)
Loading

Greploops — Automatically fix all review issues by running /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.
Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.

Reviews (2): Last reviewed commit: "fix" | Re-trigger Greptile

@bajrangCoder

This comment was marked as outdated.

@bajrangCoder bajrangCoder merged commit 3f753cd into Acode-Foundation:main Apr 4, 2026
7 checks passed
@bajrangCoder bajrangCoder deleted the fix/shift-touch-selection branch April 4, 2026 19:37
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