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

Skip to content

Conversation

@siketyan
Copy link
Member

@siketyan siketyan commented Nov 3, 2025

Summary

Fixed that the LSP server returns an error if the formatter is completely disabled in the configuration or disabled in an override for the file. It caused the IDE/editor to pop-up an error even if the user configured to disable formatter explicitly.

Test Plan

Tested on my machine with the VS Code extension.

Docs

N/A

@siketyan siketyan requested review from a team November 3, 2025 08:23
@siketyan siketyan self-assigned this Nov 3, 2025
@changeset-bot
Copy link

changeset-bot bot commented Nov 3, 2025

🦋 Changeset detected

Latest commit: 1dd9572

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 Nov 3, 2025
Comment on lines -35 to -42
if session.workspace.is_path_ignored(PathIsIgnoredParams {
path: path.clone(),
project_key: doc.project_key,
features,
ignore_kind: IgnoreKind::Ancestors,
})? {
return Ok(None);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

WorkspaceServer::file_features() will also check if the file is ignored, so this is redundant.

Comment on lines -53 to -58
&& !session.workspace.is_path_ignored(PathIsIgnoredParams {
path: path.clone(),
project_key: doc.project_key,
features,
ignore_kind: IgnoreKind::Ancestors,
})?
Copy link
Member Author

Choose a reason for hiding this comment

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

This was also a redundant call of WorkspaceServer::is_path_ignored().

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Walkthrough

Refactors the LSP formatting handler for a linear flow: early feature-support guard, file size check, formatting call, optional HTML post-processing, and unified text-edit creation. Removes nested path-ignored guards, standardises formatted-range computation (including Vue/Astro/Svelte offsets), and consolidates HTML augmentation. Updates notify_user to return an Option via Result to handle ignored/protected/extension_error states and prevents user notifications when formatting is disabled. Adds a changeset patch noting that the Biome Language Server no longer returns an internal error when the formatter is disabled.

Suggested labels

A-Formatter

Suggested reviewers

  • ematipico
  • arendjr

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "fix(lsp): do not return error if the formatter is disabled" directly addresses the main objective of the changeset: preventing the LSP server from returning an error when the formatter is disabled. The changes in formatting.rs reflect this exact fix through introducing an early guard that checks if formatting is supported before proceeding, and the revised notify_user function prevents emitting notifications when the feature is disabled. The title is concise, specific, and clearly communicates the primary change without unnecessary detail.
Description Check ✅ Passed The description is clearly related to the changeset, explaining both the problem (LSP server returning errors when formatter is disabled) and its user-facing impact (IDE/editor error pop-ups). This aligns well with the actual code changes that add an early guard for disabled formatters and refactor error handling through the notify_user mechanism. The description provides sufficient context without requiring extensive detail.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent 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 93d6aed and 1dd9572.

📒 Files selected for processing (1)
  • .changeset/swift-plants-jam.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/swift-plants-jam.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). (7)
  • GitHub Check: Test Node.js API
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Documentation
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: autofix

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: 2

📜 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 3e54958 and 93d6aed.

📒 Files selected for processing (2)
  • .changeset/swift-plants-jam.md (1 hunks)
  • crates/biome_lsp/src/handlers/formatting.rs (5 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/*.md: In changeset files, only use #### or ##### headers
Changesets should describe user-facing changes; internal-only changes do not need changesets
Use past tense for what you did in the changeset description and present tense for current behavior
For bug fixes, start the changeset description with a link to the issue (e.g., Fixed #1234: ...)
When referencing a rule or assist in a changeset, include a link to the rule/assist page on the website
Include a code block in the changeset when applicable to illustrate the change
End every sentence in a changeset with a full stop (.)

Files:

  • .changeset/swift-plants-jam.md
**/*.{rs,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Format Rust and TOML files before committing (e.g., via just f)

Files:

  • crates/biome_lsp/src/handlers/formatting.rs
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Document rules, assists, and their options with inline rustdoc in the Rust source

Files:

  • crates/biome_lsp/src/handlers/formatting.rs
🧠 Learnings (14)
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
Repo: biomejs/biome PR: 7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.

Applied to files:

  • .changeset/swift-plants-jam.md
📚 Learning: 2025-10-26T15:28:00.951Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-10-26T15:28:00.951Z
Learning: Applies to .changeset/*.md : Changesets should describe user-facing changes; internal-only changes do not need changesets

Applied to files:

  • .changeset/swift-plants-jam.md
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/**/*.rs : After generation, remove usages of `format_verbatim_node` and implement real formatting with biome_formatter utilities

Applied to files:

  • crates/biome_lsp/src/handlers/formatting.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import and use the `FormatNode` trait for AST nodes

Applied to files:

  • crates/biome_lsp/src/handlers/formatting.rs
📚 Learning: 2025-10-24T21:24:58.650Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.650Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/**/lint/**/*.rs : Use options/full_options/use_options code block modifiers as specified to demonstrate configuration in docs; keep modifier order consistent

Applied to files:

  • crates/biome_lsp/src/handlers/formatting.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Implement the `Format` trait for your node type and use `JsFormatter` with `write!`/`format_args!` to define formatting

Applied to files:

  • crates/biome_lsp/src/handlers/formatting.rs
📚 Learning: 2025-10-24T21:24:58.650Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.650Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/**/lint/**/*.rs : Provide informative diagnostics: explain what the error is, why it triggers, and what to do (prefer a code action or a note)

Applied to files:

  • crates/biome_lsp/src/handlers/formatting.rs
📚 Learning: 2025-10-24T21:24:58.650Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.650Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/**/lint/**/*.rs : Prefer conventional naming families when applicable: use<Framework>..., noConstant<Concept>, noDuplicate<Concept>, noEmpty<Concept>, noExcessive<Concept>, noRedundant<Concept>, noUnused<Concept>, noUseless<Concept>, noInvalid<Concept>, useValid<Concept>, noUnknown<Concept>, noMisleading<Concept>, noRestricted<Concept>, noUndeclared<Concept>, noUnsafe<Concept>, useConsistent<Concept>, useShorthand<Concept>

Applied to files:

  • crates/biome_lsp/src/handlers/formatting.rs
📚 Learning: 2025-10-26T15:28:00.951Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-10-26T15:28:00.951Z
Learning: Applies to **/*.{rs,toml} : Format Rust and TOML files before committing (e.g., via `just f`)

Applied to files:

  • crates/biome_lsp/src/handlers/formatting.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/lib.rs : Add the provided AsFormat, IntoFormat, and iterator plumbing code to lib.rs

Applied to files:

  • crates/biome_lsp/src/handlers/formatting.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/cst.rs : Create FormatHtmlSyntaxNode in cst.rs implementing FormatRule<HtmlSyntaxNode> and AsFormat/IntoFormat for HtmlSyntaxNode using the provided plumbing

Applied to files:

  • crates/biome_lsp/src/handlers/formatting.rs
📚 Learning: 2025-10-24T21:24:58.650Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.650Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/**/lint/**/*.rs : Avoid deep indentation by using combinators (map, filter, and_then) rather than nested if-let/unwrap chains

Applied to files:

  • crates/biome_lsp/src/handlers/formatting.rs
📚 Learning: 2025-10-15T09:25:05.698Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:25:05.698Z
Learning: Applies to crates/biome_service/src/workspace.rs : Implement and expose the Workspace trait in src/workspace.rs

Applied to files:

  • crates/biome_lsp/src/handlers/formatting.rs
📚 Learning: 2025-10-15T09:25:05.698Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:25:05.698Z
Learning: Applies to crates/biome_service/src/workspace/watcher.tests.rs : Place watcher tests related to workspace methods in src/workspace/watcher.tests.rs

Applied to files:

  • crates/biome_lsp/src/handlers/formatting.rs
🧬 Code graph analysis (1)
crates/biome_lsp/src/handlers/formatting.rs (5)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (13)
  • CheckFileSizeParams (9667-9670)
  • FeatureKind (11-17)
  • FeaturesSupported (21-21)
  • FileFeaturesResult (18-20)
  • FormatFileParams (9819-9822)
  • FormatOnTypeParams (9847-9851)
  • FormatRangeParams (9842-9846)
  • GetFileContentParams (9675-9678)
  • TextEdit (9413-9416)
  • TextSize (9418-9418)
  • TextRange (9395-9395)
  • BiomePath (9-9)
  • Format (8844-8848)
crates/biome_service/src/workspace/server.rs (1)
  • file_features (1110-1132)
crates/biome_service/src/file_handlers/vue.rs (3)
  • output (43-54)
  • input (34-39)
  • start (57-59)
crates/biome_service/src/file_handlers/svelte.rs (3)
  • output (43-54)
  • input (34-39)
  • start (57-59)
crates/biome_lsp/src/utils.rs (1)
  • text_edit (29-95)
⏰ 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). (7)
  • GitHub Check: Documentation
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix
🔇 Additional comments (2)
crates/biome_lsp/src/handlers/formatting.rs (2)

42-44: Excellent fix for the disabled formatter issue.

The early guard correctly prevents errors when formatting is disabled, addressing the PR objective. The notify_user helper appropriately returns Ok(None) for disabled features rather than an error.


252-270: Well-designed helper function.

The notify_user function elegantly handles the three states: disabled (returns Ok(None)), ignored/protected (returns appropriate errors), and unsupported extensions. This design prevents user-facing errors when the formatter is intentionally disabled.

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Just a suggestion for improve the changset

@siketyan siketyan merged commit ffae203 into biomejs:main Nov 3, 2025
13 checks passed
@github-actions github-actions bot mentioned this pull request Nov 3, 2025
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.

2 participants