fix(lsp): match wildcard root markers like *.cabal - #41169
Open
LinHoMo wants to merge 1 commit into
Open
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.
Issue for this PR
Closes #41168
Type of change
What does this PR do?
Filesystem.up()inpackages/opencode/src/util/filesystem.tswalks up the directory tree and yields any target it finds, but it only ever does a literalexists(join(current, target))probe. Four language servers declare their root with glob markers, so that probe can never match them:HLS->*.cabalTerraformLS->*.tfJuliaLS->*.jlSourceKit->*.xcodeproj,*.xcworkspaceexists("/repo/pkg-a/*.cabal")is always false, soNearestRootyields nothing and silently falls back to the workspace root. In a multi-package Haskell repo every package ends up with the repo root as its LSP root, and the same happens for Terraform submodules, Julia packages and Xcode projects.Fix: when a target contains
*, scan the directory withGlob.scaninstead of probing an exact path.include: "all"is required rather than"file", because*.xcodeprojand*.xcworkspaceare directory bundles, not files.Literal targets keep the existing
existspath, so their behaviour is unchanged.Filesystem.upis only consumed bylsp/server.ts, so the blast radius is limited to root detection.How did you verify your code works?
Added
packages/opencode/test/lsp/glob-root.test.ts. It builds temp workspaces containing*.cabal,*.tf,*.jland an*.xcodeprojdirectory, and asserts each server resolves the nested package directory instead of the workspace root, plus one literal-marker case as a control.up()change: 4 fail, 1 pass (the literal control still passes). So the test genuinely guards this behaviour rather than passing either way.Run with
bun test test/lsp/glob-root.test.tsfrompackages/opencode.oxlintreports no new errors on the two touched files.Caveat: I don't have the Haskell/Swift/Julia toolchains installed, so this verifies root resolution only, not a live language server session.
Screenshots / recordings
Not a UI change.
Checklist