ymac
419d1c4b67
fix(editor): 保存保持文件原有行尾,不再把 CRLF 文件写成 LF(#871)
编辑器传送的永远是 LF 文档(CodeMirror 没有别的行模型),`fs.write` 原样落盘,
于是在 Windows 检出上「改一行」= 整文件 diff。
- `text-encoding.ts`:`encodingOfFile` 扩成 `fileFormatOf(path)`,同一趟 64 KiB sniff
同时给出 `{ encoding, eol }`;新增 `detectEol` / `restoreEol`(口径与宿主
dsh-fs-local 的 detectLineEndings / restoreLineEndings 一致:前 4096 字符多数票、
孤立 \r 不计票也不改写、还原前先归一化以免 \r\r\n)。
- `index.ts` 的 `fs.write`:落盘改为 `encodeText(restoreEol(content, eol), encoding)`。
客户端零改动,所有保存入口自动覆盖;新文件仍是 UTF-8 + LF(项目级行尾约定另议)。
- 测试:text-encoding 补 3 条、fs-write-route 补 3 条端到端;拿掉 restoreEol 调用即 2 条红。
- 文档:设计文档 docs/plans/2026-10-06-preserve-eol-on-save.md、CHANGELOG、AGENTS §5 保存语义。
顺带核实(写进设计文档):宿主 `edit` 工具会保住行尾(editText 走 restoreLineEndings),
宿主 `write` 工具不会(writeText 原样写模型文本),那一半插件无权干预。