Skip to content

Jump to a line number in the preview panel #223

Description

@jongio

Problem

Reviewing a long file in the preview panel, there is no fast way to jump to a specific line. Only top (g) and bottom (G) exist. When a build error or review comment points at line 428, you have to scroll there by hand.

Proposed solution

Add a "go to line" prompt in the preview panel. A key (for example :) opens a small input, the user types a line number, and the preview scrolls to that line and centers it when possible.

  • Parse the entered number, clamp it to the file bounds (line 1 to last line).
  • Center the target line in the viewport when there is room, otherwise scroll to the nearest valid position.
  • Escape cancels the prompt with no change.

This is distinct from searching inside the preview: this is direct navigation to a known line number, not text matching.

Acceptance criteria

  • A documented keybinding opens a go-to-line prompt in the preview panel.
  • Entering a valid line number scrolls to and highlights or centers that line.
  • Out-of-range input clamps to the first or last line instead of erroring.
  • Non-numeric or empty input is rejected without changing the view.
  • Escape cancels the prompt.
  • The behavior works with word-wrap and line-number modes on or off.
  • Unit test covers clamping and the target scroll offset calculation.
  • Keybinding appears in the help overlay and internal/keybindings/keybindings.json.

Notes

  • Touches internal/panels/preview/preview.go.
  • Single PR, no new dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dx-ideaFeature idea generated by idea-generatorenhancementNew feature or requestidea-generatorGenerated by idea-generator

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions