refactor(lsp): unify command detection - #775
Closed
beruro wants to merge 1 commit into
Closed
Conversation
Collaborator
Author
|
Superseded by #780, which preserves this change as an independent commit and has passed the consolidated CI suite. The source branch is retained for recovery. |
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.
Problem
The LSP crate had three independent implementations for checking whether a command exists. One explicitly forwarded the app-adjusted PATH while the lint and workspace-scan copies did not, so installed-tool results could differ by surface and future platform fixes had to be repeated.
Solution
Introduce one crate-owned command detection helper and route LSP discovery, package-manager selection, install preflight, lint-tool detection, and both workspace scan paths through it. The helper explicitly forwards the current PATH, preserves Windows console suppression, and keeps the existing public
commands::discovery::command_existsentry point as a re-export for compatibility. Regression tests cover a known platform shell and a guaranteed-missing command.Potential risks
Tool availability now consistently uses the explicit-PATH behavior that discovery already used. This could make a previously inconsistent lint surface recognize a tool added to the app process PATH, which is the intended convergence. Command execution count and timing remain unchanged; no cache was added, avoiding stale results after PATH changes. Rollback is a single-commit revert.
Architecture and performance
Verification
cargo fmt --all -- --check— passed after formatting.cargo test -p lsp --lib— 112 passed.cargo clippy -p lsp --all-targets --no-deps -- -D warnings— passed.git diff --check— passed.