summaryrefslogtreecommitdiff
path: root/core
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
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')
-rw-r--r--core/hunks.zig5
-rw-r--r--core/lib_syntax.zig3
2 files changed, 6 insertions, 2 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 {
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).