Skip to content

fix(lsp): changes file corruption#9528

Merged
ematipico merged 1 commit intomainfrom
fix/lsp-utils
Mar 17, 2026
Merged

fix(lsp): changes file corruption#9528
ematipico merged 1 commit intomainfrom
fix/lsp-utils

Conversation

@ematipico
Copy link
Member

Summary

Closes #9341

I used Claude Code for the fix.

Test Plan

Added a new test. Green CI

Docs

@changeset-bot
Copy link

changeset-bot bot commented Mar 17, 2026

🦋 Changeset detected

Latest commit: 29ce131

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 Mar 17, 2026
@ematipico ematipico requested review from a team March 17, 2026 17:21
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f9bc3680-2569-4e49-8fcd-b929d6e294d9

📥 Commits

Reviewing files that changed from the base of the PR and between bc709f6 and 29ce131.

📒 Files selected for processing (2)
  • .changeset/fix-lsp-char-boundary-crash.md
  • crates/biome_lsp/src/utils.rs

Walkthrough

This pull request fixes an LSP crash that corrupted file content during save operations with format-on-save enabled. The root cause was improper handling of document change sequences where incremental edits preceded full document replacements. The fix modifies the apply_document_changes function to skip stale incremental changes when a subsequent full document replacement occurs, ensuring only relevant edits are applied. Regression tests validate the corrected behaviour with multi-byte UTF-8 content and offset handling.

Suggested labels

A-LSP, A-Formatter

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly refers to the core issue: fixing LSP-related file corruption during save operations.
Description check ✅ Passed The description links to issue #9341, discloses AI assistance per guidelines, mentions test coverage, and confirms CI success.
Linked Issues check ✅ Passed The PR fixes the LSP crash and file corruption by reworking apply_document_changes to skip stale incremental edits when a full document replacement occurs [#9341].
Out of Scope Changes check ✅ Passed All changes—the changeset metadata, LSP utility fix, and regression tests—are directly scoped to resolving the file corruption bug reported in #9341.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/lsp-utils
📝 Coding Plan
  • Generate coding plan for human review comments

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

Tip

CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.

Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present.

@ematipico ematipico merged commit 61451ef into main Mar 17, 2026
13 checks passed
@ematipico ematipico deleted the fix/lsp-utils branch March 17, 2026 19:49
@github-actions github-actions bot mentioned this pull request Mar 17, 2026
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.

LSP crashes on save and corrupts file content — "assertion failed: self.is_char_boundary(n)" at utils.rs:405

2 participants