summaryrefslogtreecommitdiff
path: root/core/hunks.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-21 05:30:58 -0300
committerGabriel Schneider <[email protected]>2026-11-21 05:31:07 -0300
commited0103e9738e3cf5a7c7a91aec5adf0be2fc409a (patch)
tree99add792416c5827ce515e892f2de3274225ab30 /core/hunks.zig
parentd04f4acfb9af968caaa53d6cf10a486622c95400 (diff)
downloadpardes-ed0103e9738e3cf5a7c7a91aec5adf0be2fc409a.tar.gz
pardes-ed0103e9738e3cf5a7c7a91aec5adf0be2fc409a.zip
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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/hunks.zig')
-rw-r--r--core/hunks.zig5
1 files changed, 4 insertions, 1 deletions
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 {