apply_diff reports a user edit that removed the BOM, and write_to_file drops the BOM it was given
維護者通常 3 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 50/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- typescript
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- TypeScript
- 星號
- 2k
- 分支
- 301
- 平均合併
- 3 天 14 小時
- 30 天內合併 PR
- 103
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Zoo-Code-Org/Zoo-Code 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
Zoo-Code-Org/Zoo-Code#2773 · 1 則留言 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
Zoo-Code-Org/Zoo-Code#2717 · 1 則留言 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 77/100
Zoo-Code-Org/Zoo-Code#2515 ·
維護者通常 3 天內回覆
-
fix(scripts): stryker-diff.mjs spawns the extensionless .bin shim and cannot run on Windows可能已有人在做 @easonLiangWorldedtech 於 16 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
Zoo-Code-Org/Zoo-Code#2514 ·
維護者通常 3 天內回覆
-
[BUG] search_files hides matching text on long lines可能已有人在做 @DananjayaNadun 於 9 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 74/100
Zoo-Code-Org/Zoo-Code#2496 · 1 則留言 · 已指派 1 人 ·
維護者通常 3 天內回覆
查看 Zoo-Code-Org/Zoo-Code 的全部 Issue
相似的 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
ci
難度 2/5 1-3 小時 新手友好度 78/100
ClickHouse/clickhouse-js#1248 ·
維護者通常 1 天內回覆
-
E2E: Darlehen-Test wartet auf die gebuchte Auszahlung, bevor er zur Liquiditätsvorschau wechselt未關閉technik
難度 2/5 1-3 小時 新手友好度 78/100
-
bug
難度 2/5 1-3 小時 新手友好度 67/100
SR5-FoundryVTT/SR5-FoundryVTT#2162 ·
維護者通常 1 天內回覆
-
enhancement good first issue
難度 2/5 1-3 小時 新手友好度 84/100
AhmedNAgy25/analysor#25 ·
維護者通常 1 天內回覆