fix: don't prompt when all workspace folders share one Bazel workspace#666
Open
omri-steinmetz wants to merge 1 commit into
Open
fix: don't prompt when all workspace folders share one Bazel workspace#666omri-steinmetz wants to merge 1 commit into
omri-steinmetz wants to merge 1 commit into
Conversation
In a multi-root VS Code workspace, fromWorkspaceFolders() always showed a workspace-folder quick pick. When it ran without a user gesture (e.g. the target-completion refresh at activation), the pick resolved to undefined and the extension logged "Failed to find a Bazel workspace" even though every folder belonged to the same Bazel workspace. Resolve each folder to its Bazel workspace first: if none qualify, return undefined silently; if they all map to a single Bazel workspace root, use it without prompting; only show the picker when the folders span multiple distinct Bazel workspaces. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
In a multi-root VS Code workspace,
BazelWorkspaceInfo.fromWorkspaceFolders()unconditionally callsvscode.window.showWorkspaceFolderPick(). When it runs without a user gesture — e.g. the Bazel target completion-provider refresh right after activation — the pick resolves toundefinedand the extension logs:This happens even when every workspace folder belongs to the same Bazel workspace (a common monorepo layout: a root folder plus per-package/per-service subfolders in a
.code-workspace). There is nothing for the user to disambiguate, and no setting to suppress the error.Related: #446 covers the non-Bazel-repo case; this covers the multi-root single-Bazel-workspace case.
Fix
Resolve each workspace folder to its Bazel workspace root first (via the existing
fromWorkspaceFolder), then:undefinedsilently (no folder is a Bazel workspace; also reduces noise for the "Failed to find a Bazel Workspace file" on non bazel repos that include BUILD files #446 scenario);Testing
npm run typecheck,eslint,prettier --check, andnpm run buildpass.xvfb-run -a npm run test:unit: 123 passing, 1 failing — the same pre-existinglcov parser / function coverage detailsfailure occurs on unpatched master in the same environment (Rust demangling difference), unrelated to this change.🤖 Generated with Claude Code