Skip to content

fix(commands): show line range in goto prompt#1983

Merged
bajrangCoder merged 2 commits intoAcode-Foundation:mainfrom
bajrangCoder:fix/goto-line-range-hint
Mar 27, 2026
Merged

fix(commands): show line range in goto prompt#1983
bajrangCoder merged 2 commits intoAcode-Foundation:mainfrom
bajrangCoder:fix/goto-line-range-hint

Conversation

@bajrangCoder
Copy link
Copy Markdown
Member

Fixes: #1979

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 27, 2026

Greptile Summary

This PR enhances the "Go to line" command (goto) to display the total number of lines in the current document inside the prompt message (e.g. Enter line number (1..250)), addressing issue #1979.

Key changes:

  • editor is now destructured from editorManager before prompt() is awaited (moved up from its original position after the prompt) so that editor.state.doc.lines can be read to build the range message.
  • A conditional message string is constructed: if lastLine is truthy, the range (1..N) is appended; otherwise the original string is used unchanged.
  • The editor reference obtained before the prompt is reused for the gotoLine call after the prompt, which introduces a subtle stale-reference risk (see inline comment).

Confidence Score: 4/5

Safe to merge with one targeted fix: re-read the active editor after the prompt resolves to avoid a stale reference on gotoLine.

The feature itself is correct and the UX improvement is clear. The only concern is a minor behavioural regression where the editor reference used for gotoLine is now captured before the async prompt instead of after it. This is an edge case on mobile but is a real regression worth fixing before merge.

src/lib/commands.js — specifically the goto function around lines 142–153.

Important Files Changed

Filename Overview
src/lib/commands.js Moves editor destructuring before the prompt to derive total line count for the prompt message; introduces a minor stale-reference risk on the gotoLine call.

Sequence Diagram

sequenceDiagram
    participant User
    participant goto as goto()
    participant editorManager
    participant prompt as prompt()
    participant editor as editor

    User->>goto: trigger "Go to line"
    goto->>editorManager: destructure editor
    editorManager-->>goto: editor reference (snapshot)
    goto->>editor: read state.doc.lines (lastLine)
    editor-->>goto: line count (e.g. 250)
    goto->>prompt: show "Enter line number (1..250)"
    prompt-->>goto: user input (e.g. "42.5")
    goto->>goto: parse lineStr, colStr
    goto->>editor: gotoLine(lineStr, colStr) — uses snapshot editor
Loading

Reviews (1): Last reviewed commit: "fix(commands): show line range in goto p..." | Re-trigger Greptile

@bajrangCoder bajrangCoder merged commit 61aca01 into Acode-Foundation:main Mar 27, 2026
6 checks passed
@bajrangCoder bajrangCoder deleted the fix/goto-line-range-hint branch March 27, 2026 07:23
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.

Enhanced “Jump to Line” functionality

1 participant