From 82551f77833a09b313bd3e58371582abd1aedcc4 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 27 Sep 2026 22:27:42 -0300 Subject: Move looking out of pardes.zig into look.zig Pure move, no behaviour change (acme keeps this in look.c): expanding the word under a click (ExpandedWord, expandedWord, expandedSel, cursorWordSel), the n/N walk (LookFrom, lookEdge, lookStand, lookWalkPanes, lookPast, wholeRowSpan, lookSpanIn, lookWalk, landLookSpot, noteLookSource, armLookWalk), search results (Search, SearchStart, submitSearch, lookFirstHit, runSearch, searchStep, jumpResult), the look-hover preview (LookHoverWait, LookHoverPreview, FileWordSpan, PdfWordPreview, invalidateLookHover, cancelLookHover, lookHoverPane, noteLookHover, refreshLookHoverFromRaw, advanceLookHover) and lookAt with its targets (focusPaneLine, selectSpan, openPaneTarget, focusPaneByPath, clearNavigationSelection, resolveLookTarget, locationText, canonicalLookLocation, pdfLinkLocation, followPdfLink), with five tests, go verbatim to the end of look.zig after its word and target resolution. The methods become free functions taking `p: *Pardes`; their 143 call sites change from `p.lookAt(..)` to `look.lookAt(p, ..)` (tests reach them as `pardes.look.x`). Inside look.zig the moved code's `look.` prefix drops. Co-Authored-By: Claude Opus 5.5 --- test/fs_namespace.zig | 2 +- test/output.zig | 10 +++++----- test/panes.zig | 10 +++++----- test/pdf.zig | 14 +++++++------- test/perf.zig | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig index ec94b509..470615c9 100644 --- a/test/fs_namespace.zig +++ b/test/fs_namespace.zig @@ -224,7 +224,7 @@ test "virtual file opens do not request OS watches" { test "Look at a virtual file opens one pane and failed opens release their slot" { const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); - p.lookAt(0, "/virtual/index"); + pardes.look.lookAt(p, 0, "/virtual/index"); var opened: usize = 0; for (p.panes) |slot| { const pane = slot orelse continue; diff --git a/test/output.zig b/test/output.zig index ebea79d4..b4c018db 100644 --- a/test/output.zig +++ b/test/output.zig @@ -610,7 +610,7 @@ test "EffectCode lists readable virtual sources used by this backend" { } try std.testing.expect(count >= 3); const report = p.active; - p.lookAt(report, backend_source); + pardes.look.lookAt(p, report, backend_source); try std.testing.expect(p.active != report); const source = p.panes[p.active].?.file.?; try std.testing.expectEqualStrings(backend_source, source.path); @@ -722,7 +722,7 @@ test "n/N in ordinary text skips comment slashes and retains real paths" { defer p.deinit(); const pane = try p.setTestFile("// ordinary comment\n/// documentation comment\n(//) [///] punctuation\n/\n// /tmp\n//tmp\n"); try std.testing.expect(pane.file.?.output == null); - p.armLookWalk(0); + pardes.look.armLookWalk(p, 0); const available = p.freeSlot(); for ([_]struct { key: u21, row: i32, text: []const u8 }{ .{ .key = 'n', .row = 3, .text = "/" }, @@ -796,7 +796,7 @@ test "n/N skips formatted context and selects comment match locations" { try p.dumpState(); const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); - restored.armLookWalk(id); + pardes.look.armLookWalk(restored, id); const restored_result = restored.panes[id].?; restored.update(.{ .key = .{ .cp = 'n' } }); try std.testing.expectEqual(@as(i32, @intCast(matches[0])), restored_result.cur_row); @@ -1562,7 +1562,7 @@ test "stacked search and LSP results retain source tint navigation and dump owne try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.number), file.highlights[number]); p.active = id; pane.mode = .normal; - p.armLookWalk(id); + pardes.look.armLookWalk(p, id); for ([_]struct { key: u21, match: usize }{ .{ .key = 'n', .match = 0 }, .{ .key = 'n', .match = 1 }, .{ .key = 'N', .match = 0 } }) |step| { p.update(.{ .key = .{ .cp = step.key } }); try std.testing.expectEqual(@as(i32, @intCast(matches[step.match])), pane.cur_row); @@ -1585,7 +1585,7 @@ test "stacked search and LSP results retain source tint navigation and dump owne try std.testing.expectEqualSlices(u8, before.colors, after.colors); } restored.active = id; - restored.armLookWalk(id); + pardes.look.armLookWalk(restored, id); restored.update(.{ .key = .{ .cp = 'N' } }); try std.testing.expectEqual(@as(i32, @intCast(matches[1])), restored.panes[id].?.cur_row); try std.testing.expectEqualStrings(source_text, source.file.?.content); diff --git a/test/panes.zig b/test/panes.zig index e865641f..f45d42b2 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -494,7 +494,7 @@ const TreeContextTests = struct { defer frame.deinit(); _ = try p.render(frame.allocator()); try std.testing.expectEqual(@as(i32, 0), pane.scroll()); - p.lookAt(0, "/tree-context.zig:60"); + pardes.look.lookAt(p, 0, "/tree-context.zig:60"); try std.testing.expectEqual(@as(usize, 0), p.active); try std.testing.expectEqual(@as(i32, 59), pane.cur_row); const surface = try p.render(frame.allocator()); @@ -4469,7 +4469,7 @@ const LookResetTests = struct { const pane = try p.setTestFile("alpha\nbravo\ncharlie\nneedle\n"); try seed(pane, "/test.txt:3:2"); // This operand is released by Look's selection cleanup. - p.lookAt(0, pane.pointer_selections[0].?.raw_text.?); + pardes.look.lookAt(p, 0, pane.pointer_selections[0].?.raw_text.?); try cleared(pane); try std.testing.expectEqual(@as(usize, 0), p.active); try std.testing.expectEqual(@as(i32, 2), pane.cur_row); @@ -4477,7 +4477,7 @@ const LookResetTests = struct { try std.testing.expect(!pane.vsel.active); try seed(pane, "/test.txt:2:2-4"); - p.lookAt(0, pane.pointer_selections[0].?.raw_text.?); + pardes.look.lookAt(p, 0, pane.pointer_selections[0].?.raw_text.?); try cleared(pane); try std.testing.expectEqual(@as(i32, 1), pane.cur_row); try std.testing.expectEqualStrings("rav", selected(pane)); @@ -4485,7 +4485,7 @@ const LookResetTests = struct { p.gpa.free(pane.file.?.path); pane.file.?.path = try p.gpa.dupe(u8, "/tmp/look-selection-source.txt"); try seed(pane, "needle"); - p.lookAt(0, pane.pointer_selections[0].?.raw_text.?); + pardes.look.lookAt(p, 0, pane.pointer_selections[0].?.raw_text.?); try cleared(pane); try std.testing.expectEqual(@as(i32, 3), pane.cur_row); try std.testing.expectEqualStrings("needle", selected(pane)); @@ -4508,7 +4508,7 @@ const LookResetTests = struct { p.active = 0; try seed(source, if (range) "/look-destination.txt:2:2-4" else "/look-destination.txt:3:2"); try seed(destination, "previous destination"); - p.lookAt(0, source.pointer_selections[0].?.raw_text.?); + pardes.look.lookAt(p, 0, source.pointer_selections[0].?.raw_text.?); try std.testing.expectEqual(id, p.active); try cleared(source); try cleared(destination); diff --git a/test/pdf.zig b/test/pdf.zig index 25d0de76..69a82123 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -135,9 +135,9 @@ const PdfLinkTests = struct { const choices_id = for (p.panes, 0..) |slot, id| { if (slot == choices) break id; } else return error.MissingPdfLinkChoices; - p.lookAt(choices_id, "https://example.com/embedded"); + pardes.look.lookAt(p, choices_id, "https://example.com/embedded"); try expectOpened(p, "https://example.com/embedded"); - p.lookAt(choices_id, "target.txt"); + pardes.look.lookAt(p, choices_id, "target.txt"); try std.testing.expectEqualStrings("chosen file\n", p.panes[p.active].?.file.?.content); p.active = 0; _ = try p.render(frame.allocator()); @@ -349,16 +349,16 @@ test "PdfSections Look follows the exact owning PDF, not an equal path" { const first_row = std.mem.sliceTo(first_output.file.?.content, '\n'); const target = first_row[0 .. std.mem.indexOfScalar(u8, first_row, ' ') orelse first_row.len]; - p.lookAt(first_output_id, target); + pardes.look.lookAt(p, first_output_id, target); try std.testing.expectEqual(@as(usize, 0), p.active); - p.lookAt(duplicate_output_id, target); + pardes.look.lookAt(p, duplicate_output_id, target); try std.testing.expectEqual(duplicate_id, p.active); // Once the original document is gone, its output cannot reinterpret an // old ordinal against the still-open equal-path duplicate. try std.testing.expect(pardes.test_api.runBuiltin(p, "Del", 0, "", null)); p.active = first_output_id; - p.lookAt(first_output_id, target); + pardes.look.lookAt(p, first_output_id, target); try std.testing.expectEqual(first_output_id, p.active); } @@ -881,7 +881,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { try std.testing.expect(pane.pdf.?.document_scroll_y > before_height_scroll); const revision_before_search = active_raster.revision; - try p.runSearch(0, "Pardes", .text, .top); + try pardes.look.runSearch(p, 0, "Pardes", .text, .top); try std.testing.expectEqualStrings("Pardes", pane.pdf.?.search_query); try std.testing.expectEqual(revision_before_search, active_raster.revision); const results_id = pane.search_pane orelse return error.MissingPdfSearchResults; @@ -1578,7 +1578,7 @@ test "PDF n/N addresses and reveals distinct MuPDF hits on one page" { p.locations_config.context = 2; p.locations_config.tscontext = true; - try p.runSearch(0, "Pardes", .text, .top); + try pardes.look.runSearch(p, 0, "Pardes", .text, .top); const results_id = pane.search_pane orelse return error.MissingPdfSearchResults; const results = p.panes[results_id].?.file.?; var found: [3]bool = @splat(false); diff --git a/test/perf.zig b/test/perf.zig index 7d3b5e3d..6ce8f014 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -445,7 +445,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u const core = try boot(); defer core.deinit(); const t0 = nowNs(); - core.lookAt(0, path); + pardes.look.lookAt(core, 0, path); pump(core); _ = try frame(core); const dt = nowNs() -| t0; @@ -459,7 +459,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u const core = try boot(); defer core.deinit(); - core.lookAt(0, path); + pardes.look.lookAt(core, 0, path); pump(core); const id = filePane(core) orelse return error.OpenDidNotOpenFile; core.active = id; -- cgit v1.3