Skip to content

fix(large-file): palette :N line jump offers scan instead of bogus jump (#2597) - #2623

Merged
sinelaw merged 1 commit into
masterfrom
claude/compassionate-newton-1vgrnl
Jul 9, 2026
Merged

sinelaw merged 1 commit into
masterfrom
claude/compassionate-newton-1vgrnl

Conversation

@sinelaw

@sinelaw sinelaw commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #2597.

In a large file opened in byte-offset mode (before a line-index scan has run), the command-palette :N line-jump path did not behave like the Ctrl+G / Go to Line flow:

  • On confirm, max_line was resolved from line_count().unwrap_or(1), clamping every target to line 1. goto_line_col(1, …) in byte-offset mode teleported the cursor to the end of the file while the status bar falsely reported "Jumped to line 1" — no scan offered.
  • While typing, the live preview jumped the cursor to a wrong byte (there is no line→offset mapping to preview against).

Ctrl+G already handled this correctly by offering the "Scan file for exact line numbers?" prompt when no line index exists.

Fix

  • Extract the shared active_buffer_has_line_index() check (previously inline in the Action::GotoLine handler).
  • In execute_quick_open_result, when the palette :N path runs against a buffer with no line index, open the same GotoLineScanConfirm prompt as Ctrl+G instead of clamping to line 1. confirm_prompt() takes the current prompt out first, so the newly-opened scan prompt survives.
  • Suppress the live :N preview when no line index exists, so the cursor stays put until the scan is offered.

After answering y, the file is scanned and the Go to Line prompt opens, exactly matching the existing Ctrl+G behavior.

Testing

  • New regression test test_palette_line_jump_offers_scan_in_large_file in large_file_mode.rs: in byte-offset mode, palette :1000 keeps the cursor at byte 0, offers the scan prompt on Enter (no "Jumped to line" message), and after y + scan lands on line 1000.
  • Full large_file_mode e2e suite passes (17 tests).
  • Manually validated in a tmux session against a 12 MB / 300k-line file: Ctrl+P → :1000 → Scan file for exact line numbers? (y/N) → y → scan builds the index → Go to line: 1000 → lands on line 1000 with "Jumped to line 1000" (cursor never teleports to EOF).
  • cargo fmt, cargo clippy -p fresh-editor --all-targets (clean; only pre-existing crate-wide lib warnings), build all green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YMKU14NH3YNSTQ1npdjTXe


Generated by Claude Code

In a large file opened in byte-offset mode (no line index yet), the
command-palette ":N" line-jump path resolved max_line from
line_count().unwrap_or(1), clamping every target to line 1. The confirm
teleported the cursor to the end of the file and reported "Jumped to line
1", and the live preview jumped the cursor to a wrong byte while typing.

Route the palette ":N" path through the same "Scan file for exact line
numbers?" flow as Ctrl+G / Go to Line when the active buffer has no line
index, and suppress the live preview in that state. Extracts the shared
`active_buffer_has_line_index` check used by both paths.

Fixes #2597.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YMKU14NH3YNSTQ1npdjTXe
@sinelaw
sinelaw merged commit bd2866d into master Jul 9, 2026
8 checks passed
@sinelaw
sinelaw deleted the claude/compassionate-newton-1vgrnl branch July 9, 2026 14:47
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.

Large files: palette ":N" line jump before a line-index scan jumps to end of file and reports "Jumped to line 1"

2 participants