mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-23 23:13:32 +00:00
fix(core): align patch Unicode matching (#38160)
This commit is contained in:
parent
0405670cab
commit
6ec17e5d55
2 changed files with 16 additions and 1 deletions
|
|
@ -200,6 +200,22 @@ describe("Patch", () => {
|
|||
)
|
||||
})
|
||||
|
||||
test("does not normalize ellipses", () => {
|
||||
expect(() =>
|
||||
Patch.derive("ellipsis.txt", [{ oldLines: ["wait..."], newLines: ["done"] }], "wait…\n"),
|
||||
).toThrow("Failed to find expected lines")
|
||||
})
|
||||
|
||||
test("prefers a later exact match over an earlier normalized match", () => {
|
||||
expect(
|
||||
Patch.derive(
|
||||
"quotes.txt",
|
||||
[{ oldLines: ['He said "hello"'], newLines: ['He said "goodbye"'] }],
|
||||
'He said “hello”\nmiddle\nHe said "hello"\n',
|
||||
).content,
|
||||
).toBe('He said “hello”\nmiddle\nHe said "goodbye"\n')
|
||||
})
|
||||
|
||||
test("matches EOF-anchored chunks from the end", () => {
|
||||
expect(
|
||||
Patch.derive(
|
||||
|
|
|
|||
|
|
@ -228,7 +228,6 @@ const normalize = (value: string) =>
|
|||
.replace(/[‘’‚‛]/g, "'")
|
||||
.replace(/[“”„‟]/g, '"')
|
||||
.replace(/[‐‑‒–—―−]/g, "-")
|
||||
.replace(/…/g, "...")
|
||||
.replace(/[\u00A0\u2002-\u200A\u202F\u205F\u3000]/g, " ")
|
||||
const splitBom = (text: string) =>
|
||||
text.startsWith("\uFEFF") ? { bom: true, text: text.slice(1) } : { bom: false, text }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue