From ed0103e9738e3cf5a7c7a91aec5adf0be2fc409a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 21 Nov 2026 05:30:58 -0300 Subject: library: a patch row's text is its line without its end, said and tested: hunks.format trims a diff line's `\r` before its `\n` (and diff.Walk.step, and each of a source's lines, so the two compare) on purpose, and nothing a consumer reads said so (toilet saw a CRLF file's rows without their `\r`); the Patch doc comment, lib_syntax's, abi/wasm.zig's record and docs/typ/building.typ (the patch view, the record's text) say it now; test/consumer: a CRLF diff stacks to the LF diff's rows with no file, and with a CRLF main.c handed in its lines still match the diff's (its declaration found above `main.c:3 *`); no code changes Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/hunks.zig | 5 ++++- core/lib_syntax.zig | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/hunks.zig b/core/hunks.zig index 98584980..bee06cc2 100644 --- a/core/hunks.zig +++ b/core/hunks.zig @@ -80,7 +80,10 @@ pub const Ctx = struct { pub const Source = struct { path: []const u8, bytes: []const u8 }; /// A diff stacked: its text, and a row for each of its lines (row i is -/// line i), the arena's; a row's path may be the diff's own bytes. +/// line i), the arena's; a row's path may be the diff's own bytes. A row's +/// text is its line without its end, the `\n` and a `\r` before it: a CRLF +/// diff's rows have no `\r` (one that must show it reads it off the diff), +/// and a source's lines are compared with the diff's so too. pub const Patch = struct { text: []const u8, rows: []const Row }; pub const Row = struct { diff --git a/core/lib_syntax.zig b/core/lib_syntax.zig index 0bb3f510..759720ec 100644 --- a/core/lib_syntax.zig +++ b/core/lib_syntax.zig @@ -72,7 +72,8 @@ pub const ground_line = syntax.ground_line; pub const Grounds = colors.Grounds; /// A unified diff stacked as pardes's patch view (its +Diff) shows it: -/// `formatPatch` gives a `Patch`, its text and a `PatchRow` a line: a +/// `formatPatch` gives a `Patch`, its text (each line without its end: no +/// `\r` from a CRLF diff) and a `PatchRow` a line: a /// hunk's `path:line`, the declarations it stands in (or git's function /// line), its lines with both their numbers, each byte's style (a `Syn` /// when `colors` are given, the grounds, the words a changed line changed). -- cgit v1.3