fix(lsp): fix hover-on-read hook — strip cat-n prefix and correct MCP param#1541
Merged
fix(lsp): fix hover-on-read hook — strip cat-n prefix and correct MCP param#1541
Conversation
… param
The hover-on-read hook was completely non-functional due to two bugs:
1. extract_symbol_positions() applied the symbol regex against the full
Read tool output which uses cat-n format (" N\t" prefix). Since the
regex is anchored at `^`, no line started with a Rust keyword and the
function always returned an empty vec, causing an early return before
any MCP calls were made.
Fix: iterate lines, detect and strip the digit-only prefix before the
first tab, convert the 1-based line number to 0-based for LSP, then
apply the regex against the stripped source line. Also removes the now-
redundant `(?m)` flag since matching is per-line.
2. The MCP `get_hover` call passed `"path"` instead of `"file_path"`, which
is the required parameter name in the mcpls tool schema.
Fixes #1532
f05abdd to
322046d
Compare
This was referenced Mar 11, 2026
Closed
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 #1532
Summary
The
hover-on-readLSP hook was completely non-functional due to two stacked bugs:Bug 1 — regex fails on cat-n output: The native
readtool returns content incat -nformat withN\tprefix. The symbol regex was applied to the full content and anchored at^, so no line ever matched —extract_symbol_positions()always returned an empty vec, causing an early return before any MCP calls.Fix: iterate lines, detect digit-only prefix before the first tab, strip it, convert 1-based line number to 0-based for LSP, apply the regex against the stripped source line. Also removes the now-redundant
(?m)multiline flag.Bug 2 — wrong MCP parameter name: The
get_hovercall passed"path"instead of"file_path", which is the required key in the mcpls tool schema.Test plan
cargo nextest run --workspace --features full --lib --bins -E 'test(hover)')handles_cat_n_prefix,cat_n_character_offset_starts_at_zero,non_digit_tab_prefix_no_symbol_match,empty_prefix_before_tab_no_symbol_match,max_symbols_zero_returns_empty,mixed_cat_n_and_raw_lines_not_supportedcargo clippy --workspace --features full -- -D warningspasses/lspshowshover injected: Nafter reading a.rsfile