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 原样写模型文本),那一半插件无权干预。
2026-10-06 15:36:36 +08:00
..
2026-10-06 00:57:35 +08:00
2026-10-05 02:35:18 +08:00
2026-09-03 20:00:08 +08:00
2026-09-28 20:11:46 +08:00
2026-09-09 11:15:30 +08:00
2026-10-05 23:42:45 +08:00
2026-10-05 02:19:58 +08:00
2026-10-05 23:38:04 +08:00
2026-10-05 23:38:04 +08:00
2026-10-05 02:13:53 +08:00
2026-09-30 01:56:11 +08:00
2026-10-05 22:57:58 +08:00
2026-10-05 02:42:09 +08:00
2026-10-05 02:13:53 +08:00
2026-09-28 20:37:56 +08:00
2026-10-05 22:32:26 +08:00
2026-10-01 18:41:27 +08:00
2026-10-06 15:36:36 +08:00
2026-08-13 09:06:55 +08:00
2026-10-05 22:58:01 +08:00
2026-10-01 17:20:06 +08:00
2026-10-05 23:38:04 +08:00
2026-09-27 22:18:35 +08:00
2026-10-05 02:10:45 +08:00
2026-10-05 03:09:38 +08:00
2026-10-01 17:10:47 +08:00
2026-09-09 11:15:30 +08:00
2026-10-01 17:18:08 +08:00
2026-10-05 00:55:34 +08:00
2026-09-27 22:18:35 +08:00
2026-09-27 22:19:05 +08:00
2026-10-06 15:36:36 +08:00
2026-10-01 17:18:31 +08:00
2026-10-05 02:19:58 +08:00
2026-09-27 22:18:14 +08:00
2026-09-27 22:18:14 +08:00
2026-09-28 20:11:46 +08:00