Skip to content

fix(lsp): fix hover-on-read hook — strip cat-n prefix and correct MCP param#1541

Merged
bug-ops merged 1 commit intomainfrom
lsp-hover-on-read
Mar 10, 2026
Merged

fix(lsp): fix hover-on-read hook — strip cat-n prefix and correct MCP param#1541
bug-ops merged 1 commit intomainfrom
lsp-hover-on-read

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 10, 2026

Fixes #1532

Summary

The hover-on-read LSP hook was completely non-functional due to two stacked bugs:

  • Bug 1 — regex fails on cat-n output: The native read tool returns content in cat -n format with N\t prefix. 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_hover call passed "path" instead of "file_path", which is the required key in the mcpls tool schema.

Test plan

  • 10 unit tests pass (cargo nextest run --workspace --features full --lib --bins -E 'test(hover)')
  • 4 new edge-case tests added by this PR: 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_supported
  • cargo clippy --workspace --features full -- -D warnings passes
  • Manual verification: /lsp shows hover injected: N after reading a .rs file

@bug-ops bug-ops enabled auto-merge (squash) March 10, 2026 22:57
@github-actions github-actions bot added rust Rust code changes core zeph-core crate bug Something isn't working size/M Medium PR (51-200 lines) labels Mar 10, 2026
… 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
@bug-ops bug-ops force-pushed the lsp-hover-on-read branch from f05abdd to 322046d Compare March 10, 2026 23:19
@bug-ops bug-ops merged commit 8b7b966 into main Mar 10, 2026
15 checks passed
@bug-ops bug-ops deleted the lsp-hover-on-read branch March 10, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lsp: hover-on-read hook never fires - regex fails on line-numbered read tool output

1 participant