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-08-10 16:46:01 +08:00
2026-08-16 19:14:57 +08:00
2026-08-10 16:46:01 +08:00
2026-08-10 16:46:01 +08:00
2026-08-21 21:39:59 +08:00
2026-08-16 23:35:57 +08:00
2026-08-20 02:09:36 +08:00
2026-08-13 10:26:57 +08:00
2026-08-18 01:22:28 +08:00
2026-09-02 23:26:04 +08:00
2026-08-12 23:04:30 +08:00
2026-08-14 23:04:25 +08:00
2026-08-17 00:06:20 +08:00
2026-08-18 10:50:30 +08:00
2026-08-14 14:53:03 +08:00
2026-08-22 19:10:02 +08:00
2026-08-15 15:05:06 +08:00
2026-08-18 23:23:17 +08:00
2026-08-18 01:22:28 +08:00
2026-08-19 04:04:44 +08:00
2026-09-02 23:37:40 +08:00
2026-10-05 21:59:14 +08:00
2026-09-06 00:59:03 +08:00
2026-10-05 22:58:01 +08:00
2026-08-24 01:19:43 +08:00
2026-08-23 22:02:47 +08:00
2026-08-24 00:59:27 +08:00
2026-09-03 09:56:31 +08:00
2026-08-26 21:40:32 +08:00
2026-08-26 18:21:43 +08:00
2026-08-29 15:49:19 +08:00
2026-09-02 23:13:57 +08:00
2026-09-01 16:07:33 +08:00
2026-09-03 21:21:22 +08:00
2026-09-04 22:08:02 +08:00
2026-09-06 23:48:25 +08:00
2026-09-08 00:04:25 +08:00
2026-09-08 22:20:15 +08:00
2026-09-08 21:21:29 +08:00
2026-09-10 17:13:32 +08:00
2026-10-05 01:58:18 +08:00
2026-09-10 22:26:02 +08:00
2026-09-09 13:15:49 +08:00
2026-09-10 17:13:32 +08:00
2026-09-10 14:54:19 +08:00
2026-09-11 16:58:29 +08:00
2026-09-11 16:20:58 +08:00
2026-09-13 23:36:24 +08:00
2026-09-27 22:19:05 +08:00
2026-09-27 22:18:19 +08:00
2026-09-21 21:00:09 +08:00
2026-09-23 23:58:59 +08:00
2026-09-23 23:58:59 +08:00
2026-10-01 16:47:43 +08:00
2026-09-27 22:19:05 +08:00
2026-09-28 18:20:08 +08:00
2026-09-27 22:18:57 +08:00
2026-09-27 22:18:57 +08:00
2026-09-28 21:38:58 +08:00
2026-09-28 11:30:29 +08:00
2026-09-29 17:54:53 +08:00
2026-10-05 00:17:08 +08:00
2026-10-06 00:06:40 +08:00
2026-10-05 22:25:51 +08:00
2026-10-05 02:50:34 +08:00
2026-10-05 23:38:04 +08:00
2026-10-06 00:55:52 +08:00
2026-10-06 15:36:36 +08:00