Skip to content

fix(core): workspace formatting#8854

Merged
ematipico merged 9 commits intonextfrom
feat/consistent-foramtting
Jan 27, 2026
Merged

fix(core): workspace formatting#8854
ematipico merged 9 commits intonextfrom
feat/consistent-foramtting

Conversation

@ematipico
Copy link
Member

Summary

This PR fixes two bugs.

Fixes #7912, where embedded formatting was incorrectly applied. I left a comment explaining the change.

The second bug is the CLI, which didn't apply formatting to the code actions when using Workspace::fix_all. This works as expected in the LSP. As you can see, there are many changes because... well, we never caught it 😅

Test Plan

Added a new test for the first bug. Updated the snapshots and tests for the second bug.

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Jan 24, 2026

🦋 Changeset detected

Latest commit: c2686a6

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

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

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 A-CLI Area: CLI A-Project Area: project A-Formatter Area: formatter A-LSP Area: language server protocol labels Jan 24, 2026
@ematipico ematipico requested a review from dyc3 January 24, 2026 13:56
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

Walkthrough

This PR replaces Execution::features() with Execution::wanted_features() and adds Execution::not_requested_features(), updating all command implementations, the runner/handler, process-file flows and tests to pass not_requested_features through SupportsFeatureParams into workspace/service calls. It introduces SupportKind::NotRequested and threads denied features through Projects/workspace file-feature resolution. Separately, it applies targeted fixes to Astro frontmatter and embedded‑HTML snippet handling and updates related tests.

Possibly related PRs

Suggested reviewers

  • dyc3
  • siketyan
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(core): workspace formatting' is concise and clearly indicates the PR addresses formatting bugs in the workspace/core, aligning with the dual bug fixes described.
Description check ✅ Passed The description clearly outlines two distinct bugs being fixed: embedded formatting in Astro files and missing formatting in CLI's fix_all, with test plan details provided.
Linked Issues check ✅ Passed The PR addresses issue #7912 by refactoring feature negotiation (wanted_features/not_requested_features) and fixing embedded formatting logic in HTML handler, preventing spurious newline insertion in Astro frontmatter. The second bug fix (CLI formatting in fix_all) is achieved through consistent feature handling across CLI and LSP.
Out of Scope Changes check ✅ Passed All changes directly support the stated objectives: refactoring feature negotiation API to properly exclude unneeded features, updating callers to use the new API, fixing embedded formatting in HTML, and updating tests. No extraneous modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

🤖 Fix all issues with AI agents
In `@crates/biome_service/src/workspace.rs`:
- Around line 544-546: Update the doc comment for the enum variant NotRequested
to fix the typo: change "It's very much ignore [SupportKind::Ignored], but it's
silent" to "It's very much like [SupportKind::Ignored], but it's silent" so the
comment correctly references SupportKind::Ignored and reads naturally.
🧹 Nitpick comments (1)
crates/biome_cli/src/runner/execution.rs (1)

17-21: Minor doc clarification.

The comment on line 20 says "should be disabled", but semantically these are features "not requested" by the command rather than features to actively disable. Consider rewording for clarity:

📝 Suggested doc improvement
     /// The features that this command requires to be enabled.
     fn wanted_features(&self) -> FeatureName;
 
-    /// The features that this command should be disabled.
+    /// The features that this command does not request (and should be ignored during negotiation).
     fn not_requested_features(&self) -> FeatureName;

Comment on lines +544 to +546
/// Particular state used when a client (e.g. CLI) doesn't require a particular feature.
/// It's very much ignore [SupportKind::Ignored], but it's silent
NotRequested,
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor typo in doc comment.

"It's very much ignore" should be "It's very much like". Quick fix:

📝 Suggested fix
-    /// Particular state used when a client (e.g. CLI) doesn't require a particular feature.
-    /// It's very much ignore [SupportKind::Ignored], but it's silent
+    /// Particular state used when a client (e.g. CLI) doesn't require a particular feature.
+    /// It's very much like [SupportKind::Ignored], but it's silent
     NotRequested,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Particular state used when a client (e.g. CLI) doesn't require a particular feature.
/// It's very much ignore [SupportKind::Ignored], but it's silent
NotRequested,
/// Particular state used when a client (e.g. CLI) doesn't require a particular feature.
/// It's very much like [SupportKind::Ignored], but it's silent
NotRequested,
🤖 Prompt for AI Agents
In `@crates/biome_service/src/workspace.rs` around lines 544 - 546, Update the doc
comment for the enum variant NotRequested to fix the typo: change "It's very
much ignore [SupportKind::Ignored], but it's silent" to "It's very much like
[SupportKind::Ignored], but it's silent" so the comment correctly references
SupportKind::Ignored and reads naturally.

Comment on lines 90 to 94
16 │ <style>#id {
> 17 font-family: comic-sans;
^^^^^^^^^^
18}
19.class {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this have a newline before the #id?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, that's a regression

Copy link
Member Author

@ematipico ematipico Jan 25, 2026

Choose a reason for hiding this comment

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

So the issue is actually bigger, and it's not a regression. With the fix we simply spotted the error that already exists

I know what's causing it, however the solution isn't clear to me yet.

I suggest merging the PR and I'll look after this in another PR. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, it would block the release of 2.4, because it still looks like a regression from the end users perspective.

Either:

  • Merge this, create a new issue to track this, and add it to the 2.4 milestone
  • Hold off until 2.4 is out

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that's one way to look at it, but also remember that this under the umbrella of the experimental full support, so regressions/mistakes/bugs/breaking changes are completely normal and under the "experimental contract". So I wouldn't be too worried about it.

Copy link
Member Author

Choose a reason for hiding this comment

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

A fix I have in mind, that doesn't require too much hassle, would be to change when diagnostics are pulled.

At the moment, when running check with --write this happens:

  • apply fixes
  • pull diagnostics
  • format

The change envision that would fix the problem is the following

  • apply fixes
  • format
  • pull diagnostics

Copy link
Contributor

Choose a reason for hiding this comment

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

I just think it would be unfortunate to ship it in this state.

Copy link
Member Author

Choose a reason for hiding this comment

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

That should be fixed now in 9f6156d (this PR)

@ematipico ematipico requested a review from dyc3 January 26, 2026 10:32
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: 1

🤖 Fix all issues with AI agents
In `@crates/biome_cli/src/runner/impls/process_file/lint_and_assist.rs`:
- Around line 95-100: The code left a dbg!(&output) call inside the
change-detection block (where output, input, changed, and
workspace_file.update_file are used); remove the dbg!(&output) line before
merging so debug stderr output isn't emitted in production — if you need runtime
logging instead, replace it with the project's logger (e.g., use the existing
logging facility) rather than dbg!.
🧹 Nitpick comments (1)
crates/biome_service/src/file_handlers/html.rs (1)

1144-1149: Doctest examples won't compile for private functions.

The examples in the rustdoc comments reference read_leading_trivia and read_trailing_trivia directly, but since these are private functions, the doctests won't run. Either add # ignore to the code blocks or convert them to unit tests if you want them validated.

Option 1: Mark examples as ignored
 /// # Examples
-/// ```
+/// ```ignore
 /// assert_eq!(read_leading_trivia("\n\tconsole.log('Hi');"), "\n\t");
Option 2: Add unit tests instead
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_read_leading_trivia() {
        assert_eq!(read_leading_trivia("\n\tconsole.log('Hi');"), "\n\t");
        assert_eq!(read_leading_trivia("console.log('Hi');"), "");
        assert_eq!(read_leading_trivia("   "), "   ");
    }

    #[test]
    fn test_read_trailing_trivia() {
        assert_eq!(read_trailing_trivia("console.log('Hi');\n"), "\n");
        assert_eq!(read_trailing_trivia("console.log('Hi');"), "");
        assert_eq!(read_trailing_trivia("   "), "");
    }
}

As per coding guidelines, doc tests should compile and pass.

Also applies to: 1177-1182

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

LGTM

ematipico and others added 8 commits January 27, 2026 14:30
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@ematipico ematipico force-pushed the feat/consistent-foramtting branch from 975ea3e to e56de71 Compare January 27, 2026 14:30
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: 3

🤖 Fix all issues with AI agents
In `@crates/biome_cli/src/commands/check.rs`:
- Around line 79-81: The not_requested_features() implementation builds an empty
set then removes search (no-op), producing the wrong feature set; update the
builder in not_requested_features() to explicitly include the search feature
(use FeaturesBuilder::new().with_search().build()) so the function returns the
"only search" set rather than an empty set—follow the same pattern used in
format.rs (with_all().without_formatter()) to express “all except X” correctly.

In `@crates/biome_lsp/src/handlers/analysis.rs`:
- Around line 83-84: The code_actions path currently sets not_requested_features
to FeaturesBuilder::new().with_search().build() but forgets to mark the
formatter as not requested; update the not_requested_features in the
code_actions call to include formatter (i.e. use
FeaturesBuilder::new().with_search().with_formatter().build()) so the formatter
is treated as not requested (keep fix_all as-is which explicitly requests
formatter).

In `@crates/biome_service/src/workspace.rs`:
- Around line 349-354: The logic is inconsistent: is_ignored() now treats
SupportKind::is_not_requested() as ignored but is_not_processed() still treats
it as processed; update the predicate in is_not_processed (and the similar
method around lines 377-388) to include support_kind.is_not_requested() where
you currently check is_ignored() or is_not_requested() so NotRequested is
treated as "not processed"/ignored consistently; adjust the iterator conditions
in the is_not_processed implementation(s) to include
support_kind.is_not_requested() alongside is_ignored() and/or is_not_requested()
as appropriate.

@ematipico ematipico merged commit 1469968 into next Jan 27, 2026
12 checks passed
@ematipico ematipico deleted the feat/consistent-foramtting branch January 27, 2026 15:27
@github-actions github-actions bot mentioned this pull request Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Formatter Area: formatter A-LSP Area: language server protocol A-Project Area: project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants