Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@fronterior
Copy link
Contributor

@fronterior fronterior commented Oct 19, 2025

Summary

The current implementation of update_workspace_folders incorrectly replaces the entire workspace folders list with only the added folders from the didChangeWorkspaceFolders event.

According to the LSP specification, the added and removed fields contain only the delta changes, not the complete list. This can be verified by logging event.added and event.removed in VSCode Extension's workspace.onDidChangeWorkspaceFolders handler.

This behavior may cause issues depending on how the plugin is implemented. When a new workspace folder is added to an already-open workspace, the existing folders are removed from the session's workspace_folders list, causing Biome diagnostics to stop working in those folders.

The official Biome VSCode extension does not experience this issue due to two implementation details:

  • It restarts the session in workspace.onDidChangeWorkspaceFolders (code)
  • When creating the LanguageClient, it provides the workspaceFolder field as an option. This prevents the LSP from receiving the DidChangeWorkspaceFolders event (code) (ref)

Therefore, this change does not affect the behavior of the official plugin.

Test Plan

I personally verified that there are no issues with the operation by adding logs in both the extension plugin and the update_workspace_folders function to observe behavior in VSCode. I believe it would be difficult to verify this behavior without adding such code.

The verification steps were as follows:

  1. Run cargo build --bin biome on the current branch to build the CLI.

  2. In the Biome Monorepo extension (which does not use the workspace field in LanguageClient), set the Biome binary path to the CLI built in step 1, build the extension, and install it in VSCode.

  3. Add a new workspace in VSCode to trigger the DidChangeWorkspaceFolders event.

  4. Check whether Biome diagnostics are visible for the focused file.

  • ASIS: Diagnostics disappeared from files in the existing workspace and did not work while editing.
  • TODO: Worked correctly.

I also confirmed that the official plugin is unaffected by setting the biome.lsp.bin configuration.
If reproduction is needed, I can share the branch used for these tests.

Docs

Currently, this change has no impact on end users.

@changeset-bot
Copy link

changeset-bot bot commented Oct 19, 2025

🦋 Changeset detected

Latest commit: 5afef18

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the A-LSP Area: language server protocol label Oct 19, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 19, 2025

Walkthrough

The PR changes LSP workspace-folder handling from replacing the entire list to performing incremental updates. The did_change_workspace_folders handler now forwards both added and removed lists to update_workspace_folders (signature changed to added: Vec<WorkspaceFolder>, removed: Vec<WorkspaceFolder>). update_workspace_folders removes folders present in removed, appends those in added, and seeds the list with added if none existed.

Possibly related PRs

  • fix(lsp): project loading #7418: Modifies Session.update_workspace_folders to accept separate added and removed lists and updates server call sites accordingly.

Suggested reviewers

  • siketyan

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title "fix(lsp): make update_workspace_folders perform incremental updates per LSP spec" is directly aligned with the main changeset. It accurately describes the core change: converting the workspace folders update logic from complete replacement to incremental delta-based updates as per the LSP specification. The title is concise, specific, and follows conventional commit format, making it immediately clear to anyone scanning the git history what this fix addresses.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
crates/biome_lsp/src/session.rs (1)

618-619: Optional: Remove trailing blank lines.

Two consecutive blank lines here—one would suffice.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9047c44 and 28a3a0d.

📒 Files selected for processing (3)
  • .changeset/fair-crabs-play.md (1 hunks)
  • crates/biome_lsp/src/server.rs (1 hunks)
  • crates/biome_lsp/src/session.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
crates/biome_*/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place core crates under /crates/biome_*/

Files:

  • crates/biome_lsp/src/session.rs
  • crates/biome_lsp/src/server.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Format Rust files before committing (e.g., via just f which formats Rust)
Document rules, assists, and options with inline rustdoc in source

Files:

  • crates/biome_lsp/src/session.rs
  • crates/biome_lsp/src/server.rs
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/*.md: In changesets, only use #### or ##### headers; other header levels are not allowed
Changesets should cover user-facing changes only; internal changes do not need changesets
Use past tense for what you did and present tense for current Biome behavior in changesets
When fixing a bug in a changeset, start with an issue link (e.g., “Fixed #1234: …”)
When referencing a rule or assist in a changeset, include a link to its page on the website
Include code blocks in changesets when applicable to illustrate changes
End every sentence in a changeset with a period

Files:

  • .changeset/fair-crabs-play.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Documentation
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test Node.js API
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: autofix
  • GitHub Check: lint
🔇 Additional comments (3)
.changeset/fair-crabs-play.md (1)

1-5: LGTM!

The changeset clearly describes the fix in past tense and follows the guidelines.

crates/biome_lsp/src/session.rs (1)

598-616: Incremental update logic looks correct.

The implementation properly handles both cases: updating existing folders (retain + extend) and initialising when none exist. The empty checks are sensible optimisations.

crates/biome_lsp/src/server.rs (1)

410-410: LGTM!

The call now correctly passes both added and removed to align with the updated API signature. The removed folders are properly used earlier (lines 390-408) to close projects before updating the list.

"@biomejs/biome": patch
---

Fixed workspace/didChangeWorkspaceFolders to perform incremental updates per LSP spec instead of replacing the entire folder list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Fixed workspace/didChangeWorkspaceFolders to perform incremental updates per LSP spec instead of replacing the entire folder list
Fixed the LSP method `workspace/didChangeWorkspaceFolders` to perform incremental updates instead of replacing the entire folder list.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/fair-crabs-play.md (1)

1-5: Consider adding an issue link if applicable.

The changeset is well-formed and compliant with most guidelines (correct frontmatter, past tense, trailing period). However, per the coding guidelines, bug-fix changesets should start with an issue link. If there's a related issue (e.g., "Fixed #1234: …"), please prepend it to the description.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86bf00d and 5afef18.

📒 Files selected for processing (1)
  • .changeset/fair-crabs-play.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/*.md: In changesets, only use #### or ##### headers; other header levels are not allowed
Changesets should cover user-facing changes only; internal changes do not need changesets
Use past tense for what you did and present tense for current Biome behavior in changesets
When fixing a bug in a changeset, start with an issue link (e.g., “Fixed #1234: …”)
When referencing a rule or assist in a changeset, include a link to its page on the website
Include code blocks in changesets when applicable to illustrate changes
End every sentence in a changeset with a period

Files:

  • .changeset/fair-crabs-play.md

@ematipico ematipico merged commit d5b416e into biomejs:main Oct 25, 2025
12 of 13 checks passed
@github-actions github-actions bot mentioned this pull request Oct 24, 2025
Jagget pushed a commit to Jagget/biome that referenced this pull request Oct 27, 2025
…er LSP spec (biomejs#7789)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Conaclos pushed a commit that referenced this pull request Nov 1, 2025
…er LSP spec (#7789)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LSP Area: language server protocol

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants