From ee5b6aa3ef0bf398c5381498af40fa93d20cf0b3 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 21 Nov 2026 01:59:49 -0300 Subject: library: the patch view without the editor: pardes-syntax exports hunks.format as `formatPatch` with its `PatchCtx` (an arena; optional `source`, `declarations` (`PatchCtx.parsed`), `colors` (`PatchCtx.languages`: highlightDiff's), `width`; their defaults no file, no declaration, no colour, code points) and its rows, `Patch`, `PatchRow` (kind other, meta, hunk, declaration, context, added, removed; the path; the line it points at; the old and the new number, each null where that side has none; location_end, code_start; a style byte a byte; no_newline, the `\\ No newline` the editor folds into the line above); format no longer makes locations.Row (it needs no editor type: the file's first half imports nothing of root.zig's) and the editor's openDiff maps its rows onto a pane's (`paneResult`, one pass, the rows as before, so the +Diff is unchanged), handing in its own source, declarations cache, colours and display width (File.displayWidth, the one use of vaxis: `width` replaces Ctx.tab); with no `colors` the formatter calls nothing of tree-sitter (the grounds and the words a changed line changed are text alone); inferEdits' 8 MiB scratch is made once a format call, not once a run of changed lines (a browser's wasm memory took 8 MiB a run, never given back in the call); test/consumer: a C diff with no file (numbered by the diff, under git's `@@` words, `foo`/`bar` emphasised, coloured as C) and with main.c handed in (its declaration from the parse above `main.c:3 *`), and in a build with no grammar (none.zig: rows, grounds and the changed `*`, no colour; a file handed in places the hunk and makes no declaration up) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/consumer/build.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test/consumer/build.zig') diff --git a/test/consumer/build.zig b/test/consumer/build.zig index fbf19f61..f8f63712 100644 --- a/test/consumer/build.zig +++ b/test/consumer/build.zig @@ -26,14 +26,16 @@ pub fn build(b: *std.Build) void { const step = b.step("test", "colour, outline and walk a C and a Zig source through pardes's syntax, build it with one language named, and edit a text with its editor and a grammar of this package's"); // A file belongs to one module: the syntax alone, and the editor (which // has it as `.syntax`), each a test of its own. - for ([_]struct { []const u8, []const u8, *std.Build.Dependency }{ .{ "lib.zig", "pardes-syntax", syntax }, .{ "editor.zig", "pardes-editor", editor } }) |t| { + // The patch view with no grammar at all: the editor's package has + // `pardes-syntax` too. + for ([_]struct { []const u8, []const u8, *std.Build.Dependency }{ .{ "lib.zig", "pardes-syntax", syntax }, .{ "editor.zig", "pardes-editor", editor }, .{ "none.zig", "pardes-syntax", editor } }) |t| { const mod = b.createModule(.{ .target = target, .optimize = optimize, .root_source_file = b.path(t[0]), .imports = &.{.{ .name = t[1], .module = t[2].module(t[1]) }}, }); - if (t[2] == editor) mod.linkLibrary(grammar); + if (std.mem.eql(u8, t[1], "pardes-editor")) mod.linkLibrary(grammar); step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mod })).step); } -- cgit v1.3