fix(vcs): preserve batched patch boundaries (#25787)

This commit is contained in:
Luke Parker 2026-05-05 10:34:06 +10:00 committed by GitHub
commit 6a5e329427
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 65 additions and 17 deletions

View file

@ -34,4 +34,20 @@ describe("session diff", () => {
expect(text(view, "deletions")).toBe("one\n")
expect(text(view, "additions")).toBe("two\n")
})
test("ignores malformed persisted patches", () => {
const diff = {
file: "a.ts",
patch:
"diff --git a/a.ts b/a.ts\nindex ff4ceb2..65a1de0 100644\n--- a/a.ts\n+++ b/a.ts\n@@ -1,3 +1,3 @@\n keep\n+add\n same\r",
additions: 1,
deletions: 1,
status: "modified" as const,
}
const view = normalize(diff)
expect(view.patch).toBe(diff.patch)
expect(text(view, "deletions")).toBe("")
expect(text(view, "additions")).toBe("")
})
})