Skip to content

🐛 LSP formatting deletes Astro frontmatter/HTML in multi-project workspaces (html.experimentalFullSupportEnabled) #11275

Description

@affanshahid

Environment information

Details
CLI:
  Version:                      2.5.6
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_DISTRIBUTION:                npm
  BIOME_LOG_PATH:                    unset
  BIOME_LOG_PREFIX_NAME:             unset
  BIOME_LOG_LEVEL:                   unset
  BIOME_LOG_KIND:                    unset
  BIOME_CONFIG_PATH:                 unset
  BIOME_THREADS:                     unset
  BIOME_WATCHER_KIND:                unset
  BIOME_WATCHER_POLLING_INTERVAL:    unset
  NO_COLOR:                     unset
  TERM:                         xterm-ghostty
  JS_RUNTIME_VERSION:           v22.22.0
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         pnpm/12.0.0-beta.2

Biome Configuration:
  Status:                       Loaded successfully.
  Path:                         biome.json
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  true
  HTML full support enabled:    unset

Workspace:
  Open Documents:               0

What happened?

With html.experimentalFullSupportEnabled: true set on an .astro file's biome.json, a specific sequence of LSP requests makes textDocument/formatting return edits that delete the frontmatter fences and the HTML body.

Repro repo: https://github.com/affanshahid/biome-astro-bug

  git clone https://github.com/affanshahid/biome-astro-bug
  cd biome-astro-bug
  pnpm install

  # Step 1: prove the CLI is unaffected
  pnpm run repro:cli
  # -> formats correctly, fences/HTML survive

  # Step 2: reproduce via the LSP
  pnpm run repro:lsp
  # -> textDocument/formatting returns edits that delete the fences and HTML

The trigger requires two things together:

  1. The LSP's workspace root must be a folder under which Biome's own project scan discovers more than one biome.json. A single-project workspace does not trigger it, even with the identical file and edits.

  2. This exact sequence on the open document: move the cursor to the end of the file, type a space, undo it, then save (which fires source.fixAll.biome followed by textDocument/formatting). The timing between these steps matters, not just which requests are sent.

Note: AI was used heavily to create the repro scripts but they are based on events captured from my live Zed session then wrapped in a script to run programatically.

Expected result

textDocument/formatting should return the same small whitespace fix the CLI produces (biome format --write), not delete the frontmatter fences and HTML body.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

Labels

A-LSPArea: language server protocolS-Bug-confirmedStatus: report has been confirmed as a valid bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions