apply_diff reports a user edit that removed the BOM, and write_to_file drops the BOM it was given
Maintainer antworten meist innerhalb von 3 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 50/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript
- Bereich
- developer-experience
Rechercherichtung
Start by tracing the apply_diff and write_to_file implementations in the extension, then inspect how they read and write files containing a UTF-8 BOM. Reproduce the report with the provided marked-file steps and compare the reported hunk with the file bytes; done means existing marks are preserved without a false user edit, and created files retain a supplied mark with an accurate report.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
A write to a file that carries a byte-order mark comes back reporting that the user edited line 1 to remove the mark. The mark is still there. A file this tool creates with a mark loses it silently, and reports the same hunk.
It is every write to a marked file, not an occasional one: four writes to marked files in one session today produced four hunks, on three edits of an existing file and one creation.
Version
Zoo Code 3.96.0 (zoocodeorganization.zoo-code), Windows 11, after a window reload, in a Git repository whose files are LF in the working tree (text=auto eol=lf, w/lf).
To reproduce
- Write a file to disk with a mark, outside the extension: bytes
EF BB BF, then# probe two, a blank line,alpha line,omega line, LF only. apply_diffthat file, one block, changing onlyomega lineon line 5.- Read the tool result's user-edits hunk: it reads the mark stripped from line 1.
- Read the file's bytes:
BOM True, first bytesb'\xef\xbb\xbf# probe two', line 5 changed.
The same hunk came back on each of three separate apply_diff calls to another marked file (PROJECT_SPEC_WALKS.md), with a byte read after each write printing BOM True. On a file created by write_to_file whose content began with U+FEFF, the same hunk came back and the bytes on disk began b'# diff p' - there the mark really was dropped.
Expected
Either the mark is preserved and no user edit is reported, or the report matches what is on disk. A write's answer should never describe a change that did not happen.
Why this matters
- It invents a person's edit. The tool result carries a user-edits hunk saying line 1 was changed by the user. A session reads that as the person's own change to a file it is editing: it re-reads and re-quotes, or it "restores" a mark that was never missing. Our project recorded the same fault on 2026-10-18, where the repair was to read the file's bytes and find the mark intact both times.
- The create path changes the file's encoding in silence. A file written by
write_to_filewith a mark is written without one, and nothing says so: the first commit records a whole-file change, and every later reader loses the encoding the author chose. - It makes real user edits hard to see. A change report that is always present is a report nobody reads, which is precisely when a person's real edit to line 1 goes by.
What we do meanwhile
- Read the exact lines immediately before the diff and copy whole lines from that read. A stale quote is what produces the refusals described below: one failing block was 149 characters against a 143-character match, six characters of drift.
- Keep a block small and on unique lines, so a refusal names one line rather than four.
- After two refusals, stop re-quoting: rewrite the whole file with
write_to_filefrom a fresh read, or make the change as a byte-level rewrite in a script. - Check the mark with a byte read, never with the tool's answer -
open(p,'rb').read(3) == b'\xef\xbb\xbf'. - Keep no marked file in a state that depends on this report: a file the tool creates is re-marked by the script that needs one.
Related, not the same fault
Three apply_diff refusals in one session read No sufficiently similar match found … needs 100% at 95%, 88% and 49%, on LF files (one with a mark, one without), so this is not line endings. The exact requirement is the intended default in dist/extension.js (fuzzyThreshold built from Hpe = 1), so it is not filed as a fault - but a person editing long wrapped Markdown meets it often, and the extension's 19 contributed settings name nothing about diffs, so there is no way to buy tolerance short of switching tool.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2k
- Forks
- 301
- Ø Merge
- 3 T. 14 Std.
- Gemergte PRs (30 T.)
- 103
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Zoo-Code-Org/Zoo-Code
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Zoo-Code-Org/Zoo-Code#2773 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Zoo-Code-Org/Zoo-Code#2717 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
Zoo-Code-Org/Zoo-Code#2515 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
fix(scripts): stryker-diff.mjs spawns the extensionless .bin shim and cannot run on WindowsEvtl. vergeben @easonLiangWorldedtech hat das vor 15 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Zoo-Code-Org/Zoo-Code#2514 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
[BUG] search_files hides matching text on long linesEvtl. vergeben @DananjayaNadun hat das vor 9 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Zoo-Code-Org/Zoo-Code#2496 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 3 Tagen
Alle Issues in Zoo-Code-Org/Zoo-Code
Ähnliche Issues
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
ci
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
ClickHouse/clickhouse-js#1248 ·
Maintainer antworten meist innerhalb von 1 Tag
-
E2E: Darlehen-Test wartet auf die gebuchte Auszahlung, bevor er zur Liquiditätsvorschau wechseltOffentechnik
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
SR5-FoundryVTT/SR5-FoundryVTT#2162 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
AhmedNAgy25/analysor#25 ·
Maintainer antworten meist innerhalb von 1 Tag