Skip to content

feat(editor): select line on CodeMirror line number gutter click#2052

Merged
bajrangCoder merged 2 commits intoAcode-Foundation:mainfrom
bajrangCoder:feat/cm-gutter-line-select
Apr 20, 2026
Merged

feat(editor): select line on CodeMirror line number gutter click#2052
bajrangCoder merged 2 commits intoAcode-Foundation:mainfrom
bajrangCoder:feat/cm-gutter-line-select

Conversation

@bajrangCoder
Copy link
Copy Markdown
Member

No description provided.

@github-actions github-actions Bot added the enhancement New feature or request label Apr 20, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 20, 2026

Greptile Summary

This PR adds line-number gutter click selection to the CodeMirror editor, wiring a new handleLineNumberClick helper into makeLineNumberExtension for both standard and relative line-number modes. Plain clicks select the full line with the cursor anchored at the line start; shift-clicks extend the current selection by whole lines. Previous review concerns (falsy || from fallback, missing shift-click support, cursor landing at the next line) are all addressed in the new implementation.

Confidence Score: 5/5

Safe to merge; all remaining findings are P2 style/UX suggestions that do not block correct behavior.

All P0/P1 concerns from prior rounds are resolved. The two open items are a minor cursor-position UX inconsistency in the downward shift-extend path and a trivial redundant wrapper — neither causes incorrect data or a broken user path.

src/cm/lineNumberSelection.ts — createExtendedLineSelection downward-direction cursor placement.

Important Files Changed

Filename Overview
src/cm/lineNumberSelection.ts New module implementing line-number gutter click selection; null-safety and cursor placement are well-handled for the plain-click path, but the downward shift-extend direction leaves the cursor one position past the trailing newline (next-line column 0).
src/lib/editorManager.js Imports and wires handleLineNumberClick into both the standard and relative-line-number configurations via lineNumberConfig.domEventHandlers; the wrapper arrow function is redundant but harmless.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Gutter click event] --> B{button === 0?}
    B -- No --> Z[ignore]
    B -- Yes --> C{alt / ctrl / meta?}
    C -- Yes --> Z
    C -- No --> D[getLineSelectionRange]
    D --> E{range resolved?}
    E -- No --> Z
    E -- Yes --> F{shiftKey?}
    F -- No --> G[createLineSelection\nanchor=to, head=from\ncursor at line start]
    F -- Yes --> H[createExtendedLineSelection\nmerge current + clicked range]
    H --> I{clicked above\ncurrent?}
    I -- Yes --> J[single to, from\ncursor at start]
    I -- No --> K[single from, to\ncursor past newline ⚠️]
    G --> L[view.dispatch + view.focus]
    J --> L
    K --> L
Loading

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

Comment thread src/cm/lineNumberSelection.ts Outdated
Comment thread src/cm/lineNumberSelection.ts Outdated
Comment thread src/cm/lineNumberSelection.ts
@bajrangCoder
Copy link
Copy Markdown
Member Author

@greptileai

@bajrangCoder bajrangCoder merged commit d97ce3c into Acode-Foundation:main Apr 20, 2026
7 checks passed
@bajrangCoder bajrangCoder deleted the feat/cm-gutter-line-select branch April 20, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant