fix(status-bar): refresh cached cursor line on plugin cursor jump (#2301)#2333
Open
sinelaw wants to merge 1 commit into
Open
fix(status-bar): refresh cached cursor line on plugin cursor jump (#2301)#2333sinelaw wants to merge 1 commit into
sinelaw wants to merge 1 commit into
Conversation
5b3cc65 to
a4a74d2
Compare
) "Go to LSP Symbol" moves the cursor through the `setBufferCursor` plugin op (`set_buffer_cursor_in_splits`), which updated the cursor position but never refreshed `state.primary_cursor_line_number`. The status bar reads the line from that cache while computing the column live, so right after the jump it reported the pre-jump line ("Ln 30") with the new column ("Col 5") until the next cursor movement recomputed the cache. Refresh the cached line number after the jump, mirroring the canonical `Window::jump_active_cursor_to` path. This fixes every plugin-driven cursor jump (Go to LSP Symbol and any other `setBufferCursor` caller), not just the LSP case. The existing `test_lsp_navigation_jumps_to_precise_column` only asserted the column, which is why the stale line went unnoticed; the new regression test asserts the full `Ln 6, Col 3` immediately after the jump, with no intervening cursor movement.
a4a74d2 to
73791b5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2301.
Problem
After Go to LSP Symbol jumps the cursor, the status bar shows the previous line number (
Ln 30) with the new column (Col 5) until the next keypress, which self-corrects it. The cursor itself lands correctly — only the status-bar line readout is stale, right after the command whose whole purpose is to navigate there.Root cause
The "Go to LSP Symbol" plugin moves the cursor through the
setBufferCursorplugin op, handled byWindow::set_buffer_cursor_in_splits. That function moved the cursor position but never refreshedstate.primary_cursor_line_number.The status bar (
status_bar.rs) reads the line from that cachedprimary_cursor_line_number, while it computes the column live from the cursor's byte position. That asymmetry is exactly the reported symptom: column updates, line is stale until any later cursor movement recomputes the cache.This is the same class of bug noted in the issue comment ("status bar not refreshed after a programmatic cursor jump") for any path that bypasses the canonical jump entry point.
Fix
Refresh the cached line number inside
set_buffer_cursor_in_splitsafter moving the cursor, mirroring the canonicalWindow::jump_active_cursor_to. This covers every plugin-driven cursor jump that usessetBufferCursor, not just the LSP symbol case.Testing
test_lsp_navigation_status_bar_line_updates_after_jump: jumps tomyMethod(file line 5) and asserts the status bar readsLn 6, Col 3immediately, with no intervening cursor movement. The pre-existingtest_lsp_navigation_jumps_to_precise_columnonly asserted the column, which is why the stale line went unnoticed.lsp_navigatione2e tests pass;cargo fmt --checkandcargo clippyare clean.https://claude.ai/code/session_015Cs1411QRfGHJzz2cjsczW
Generated by Claude Code