diff options
Diffstat (limited to 'test/output.zig')
| -rw-r--r-- | test/output.zig | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/test/output.zig b/test/output.zig index 7fb9f237..d7b8a816 100644 --- a/test/output.zig +++ b/test/output.zig @@ -69,7 +69,7 @@ test "search tint survives wrapping and theme changes while selections remain au fn outputCell(p: *Pardes, surface: *pardes.Surface, id: usize, byte: usize) *pardes.Cell { const pane = p.panes[id].?; const line = modal.lineSlice(pane.file.?.content, 0); - const rect = p.rects[id]; + const rect = p.view().rects[id]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane) + @as(u16, @intCast(panes.File.displayWidth(line[0..byte]))); const y = p.bodyTop(pane, rect); return surface.at(x, y); @@ -213,22 +213,22 @@ test "references fill the asking text's query pane: sorted under their files, th try std.testing.expectEqual(@as(usize, 6), results.query.?.total); // A list answered, not a query typed: the keyboard on its current row in // normal mode; n, Enter: the keyboard on that ref in the text - try std.testing.expectEqual(qid, p.active); + try std.testing.expectEqual(qid, p.view().active); try std.testing.expect(results.body.mode == .normal and results.body.cur_row > 0); p.update(.{ .key = .{ .cp = 'n' } }); try std.testing.expectEqual(@as(?usize, 3), source.places.current); p.update(.{ .key = .{ .cp = Key.enter } }); - try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 0), p.view().active); try std.testing.expectEqual(@as(i32, 4), source.body.cur_row); p.update(.{ .key = .{ .cp = 'N' } }); try std.testing.expectEqual(@as(?usize, 2), source.places.current); // n in the owner steps them, round the end without a word - p.active = 0; + p.view().active = 0; p.update(.{ .key = .{ .cp = 'n' } }); try std.testing.expectEqual(@as(?usize, 3), source.places.current); p.update(.{ .key = .{ .cp = 'n' } }); try std.testing.expectEqual(@as(?usize, 0), source.places.current); - try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 0), p.view().active); } test "location sorting leaves mixed prose alone and preserves newline shape" { @@ -267,8 +267,8 @@ test "a single language location opens the full spaced filename" { defer p.deinit(); p.lspRequest(0, .references, ""); pardes.lsp.Ask.lspResponse(p, p.lsp_ask.wait.?.id, "with space.zig:2:1 second\n"); - try std.testing.expect(std.mem.endsWith(u8, p.panes[p.active].?.file.?.path, "/with space.zig")); - try std.testing.expectEqual(@as(i32, 1), p.panes[p.active].?.body.cur_row); + try std.testing.expect(std.mem.endsWith(u8, p.panes[p.view().active].?.file.?.path, "/with space.zig")); + try std.testing.expectEqual(@as(i32, 1), p.panes[p.view().active].?.body.cur_row); for (p.panes) |slot| { const pane = slot orelse continue; if (pane.file) |file| try std.testing.expect(file.output == null); @@ -348,7 +348,7 @@ test "result sorting allocation failures preserve the previous answer and naviga try std.testing.expectEqualStrings("before", result.file.?.output.?.arg()); try std.testing.expectEqual(id, source.search_pane.?); try std.testing.expectEqual(@as(usize, 0), source.search_row.?); - try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 0), p.view().active); try std.testing.expectEqual(owner, p.look_walk_owner); } } @@ -385,7 +385,7 @@ test "Mini asks for no watch on its pane" { defer p.deinit(); try p.panes[0].?.setOwnedCwd(dir); try std.testing.expect(p.executeBuiltinLine(0, "Mini build.zig")); - const id = p.active; + const id = p.view().active; try std.testing.expect(id != 0); try std.testing.expect(p.executeBuiltinLine(id, "Mini build.zig")); while (p.nextEffect()) |effect| switch (effect) { @@ -401,20 +401,20 @@ test "Mini dump preserves its exact virtual snapshot and body writes detach colo var command_buf: [128]u8 = undefined; const command = try std.fmt.bufPrint(&command_buf, "Mini /virtual/pane/{d}/body", .{source.serial}); try std.testing.expect(p.executeBuiltinLine(0, command)); - const id = p.active; + const id = p.view().active; const before = p.panes[id].?.file.?; try std.testing.expect(before.mini != null); try pardes.dump.dumpState(p); panes.File.setContent(p, &source.file.?, try p.gpa.dupe(u8, "changed\n")); const restored = try pardes.dump.initFromDump(std.testing.allocator, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); - const mini = restored.panes[restored.active].?; + const mini = restored.panes[restored.view().active].?; try std.testing.expectEqualStrings(before.content, mini.file.?.content); try std.testing.expectEqualStrings(before.mini.?.source, mini.file.?.mini.?.source); try std.testing.expectEqualSlices(u8, before.mini.?.colors, mini.file.?.mini.?.colors); try std.testing.expect(before.content.ptr != mini.file.?.content.ptr); while (restored.nextEffect()) |effect| switch (effect) { - .watch => |watch| try std.testing.expect(watch.pane != restored.active), + .watch => |watch| try std.testing.expect(watch.pane != restored.view().active), else => {}, }; var body_buf: [128]u8 = undefined; @@ -438,7 +438,7 @@ test "Mini syntax colors survive themes and rendering without source access" { defer p.deinit(); try p.panes[0].?.setOwnedCwd(dir); try panes.mini.open(p, 0, "demo.zig"); - const id = p.active; + const id = p.view().active; const mini = p.panes[id].?; const keyword = std.mem.indexOfScalar(u8, mini.file.?.mini.?.colors, @backingInt(pardes.syntax.Syn.keyword)) orelse return error.MissingKeywordColor; // Direct pane construction bypasses the host update's layout sync. @@ -452,7 +452,7 @@ test "Mini syntax colors survive themes and rendering without source access" { for (0..4) |_| { mini.file.?.syntax_dirty = true; const surface = try p.render(frame.allocator()); - const rect = p.rects[id]; + const rect = p.view().rects[id]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(mini) + @as(u16, @intCast(column)); const y = p.bodyTop(mini, rect) + @as(u16, @intCast(position.row)); try std.testing.expectEqualDeep(pardes.Color{ .rgb = p.theme().kw }, surface.at(x, y).style.fg); @@ -468,7 +468,7 @@ test "DumpConfig prints the startup path" { const p = try Pardes.init(std.testing.allocator, .{ .startup_config_path = path }); defer p.deinit(); try std.testing.expect(p.executeBuiltinLine(0, "DumpConfig")); - try std.testing.expect(std.mem.indexOf(u8, p.panes[p.active].?.file.?.content, "Startup config: " ++ path ++ "\n") != null); + try std.testing.expect(std.mem.indexOf(u8, p.panes[p.view().active].?.file.?.content, "Startup config: " ++ path ++ "\n") != null); } /// The file Config names, in a fresh temporary directory: `pardes/init` @@ -489,19 +489,19 @@ test "Config opens the startup file, and a second Config goes back to its pane" const path = try configFixture(&tmp, "Theme orchard\n", &buf); const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .startup_config_path = path }); defer p.deinit(); - const first = p.active; + const first = p.view().active; try std.testing.expect(p.executeBuiltinLine(first, "Config")); - const opened = p.active; + const opened = p.view().active; try std.testing.expect(opened != first); const f = p.panes[opened].?.file.?; try std.testing.expectEqualStrings(path, f.path); try std.testing.expectEqualStrings("Theme orchard\n", f.content); try std.testing.expect(f.output == null); - p.active = first; + p.view().active = first; try std.testing.expect(p.executeBuiltinLine(first, "Config")); - try std.testing.expectEqual(opened, p.active); + try std.testing.expectEqual(opened, p.view().active); var named: usize = 0; for (p.panes) |slot| if (slot) |pane| if (pane.file) |file| { named += @intFromBool(std.mem.eql(u8, file.path, path)); @@ -516,10 +516,10 @@ test "Config with no startup file opens a pane of its name, and Save makes its d const path = try configFixture(&tmp, null, &buf); const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .startup_config_path = path }); defer p.deinit(); - const first = p.active; + const first = p.view().active; try std.testing.expect(p.executeBuiltinLine(first, "Config")); - const opened = p.active; + const opened = p.view().active; try std.testing.expect(opened != first); const f = p.panes[opened].?.file.?; try std.testing.expectEqualStrings(path, f.path); @@ -527,9 +527,9 @@ test "Config with no startup file opens a pane of its name, and Save makes its d try std.testing.expect(f.output == null); // Again: the same pane, not a second one. - p.active = first; + p.view().active = first; try std.testing.expect(p.executeBuiltinLine(first, "Config")); - try std.testing.expectEqual(opened, p.active); + try std.testing.expectEqual(opened, p.view().active); try std.testing.expectError(error.FileNotFound, tmp.dir.statFile(std.testing.io, "pardes", .{})); // Save's effect, as a host performs it. @@ -559,22 +559,22 @@ test "a window's setting builtins (TaglineSize, Font) reach the report DumpConfi .font => continue, else => setting.word, }; - try std.testing.expect(p.executeBuiltinLine(p.active, command)); + try std.testing.expect(p.executeBuiltinLine(p.view().active, command)); } if (comptime font_picker) { const before_invalid = p.settings.font.tagline_percent; - try std.testing.expect(p.executeBuiltinLine(p.active, "TaglineSize 0")); + try std.testing.expect(p.executeBuiltinLine(p.view().active, "TaglineSize 0")); try std.testing.expectEqual(before_invalid, p.settings.font.tagline_percent); const installed = fonts.list(font_arena.allocator(), null); if (installed.len > 0) { chosen_font = installed[0].name; const command = try std.fmt.bufPrint(&buf, "Font {s}", .{installed[0].name}); - try std.testing.expect(p.executeBuiltinLine(p.active, command)); + try std.testing.expect(p.executeBuiltinLine(p.view().active, command)); } } - try std.testing.expect(p.executeBuiltinLine(p.active, "DumpConfig")); - const report = p.panes[p.active].?.file.?.content; + try std.testing.expect(p.executeBuiltinLine(p.view().active, "DumpConfig")); + const report = p.panes[p.view().active].?.file.?.content; // The toggles, Theme and Shell are test/behaviour/settings.zig's, through // the root ctl; what is left is a window's (fonts). const tagline = if (!builtins.viewCapabilities(p).tagline_font_size) @@ -662,7 +662,7 @@ test "LookNext/LookPrev skips formatted context and selects comment match locati .{ .key = 'N', .match = 0 }, }) |step| { lookKey(p, step.key); - try std.testing.expectEqual(id, p.active); + try std.testing.expectEqual(id, p.view().active); const row = matches[step.match]; try std.testing.expectEqual(@as(i32, @intCast(row)), result.body.cur_row); const line = modal.lineSlice(file.content, row); @@ -696,12 +696,12 @@ test "LookNext/LookPrev selects one output location per row and opens nothing" { defer p.deinit(); p.locations_config.layout = .@"inline"; p.update(.{ .resize = .{ .cols = 100, .rows = 40 } }); - const rid = try walkFixture(p, p.active, paths.cwd, "one"); + const rid = try walkFixture(p, p.view().active, paths.cwd, "one"); const results = p.panes[rid].?; const panes_before = p.freeSlot(); lookKey(p, 'n'); - try std.testing.expectEqual(rid, p.active); + try std.testing.expectEqual(rid, p.view().active); try std.testing.expectEqual(panes_before, p.freeSlot()); try std.testing.expect(results.body.vsel.active and results.body.vsel.explicit); try std.testing.expectEqualStrings("build.zig:1:1", selectedOutputText(results) orelse ""); @@ -718,8 +718,8 @@ test "LookNext/LookPrev selects one output location per row and opens nothing" { p.update(.{ .key = .{ .cp = Key.enter } }); try std.testing.expect(p.freeSlot() != panes_before); - try std.testing.expect(std.mem.endsWith(u8, p.panes[p.active].?.file.?.path, "/build.zig")); - try std.testing.expectEqual(panes.Output.Grain.word, panes.Output.grain(p.panes[p.active].?.file.?.output)); + try std.testing.expect(std.mem.endsWith(u8, p.panes[p.view().active].?.file.?.path, "/build.zig")); + try std.testing.expectEqual(panes.Output.Grain.word, panes.Output.grain(p.panes[p.view().active].?.file.?.output)); } test "LookPrev exactly reverses LookNext across output panes and the ring seam" { @@ -730,16 +730,16 @@ test "LookPrev exactly reverses LookNext across output panes and the ring seam" defer p.deinit(); p.locations_config.layout = .@"inline"; p.update(.{ .resize = .{ .cols = 100, .rows = 40 } }); - const first = try walkFixture(p, p.active, paths.cwd, "one"); + const first = try walkFixture(p, p.view().active, paths.cwd, "one"); p.update(.{ .key = .{ .cp = 'n', .alt = true } }); - const second = try walkFixture(p, p.active, paths.cwd, "two"); + const second = try walkFixture(p, p.view().active, paths.cwd, "two"); try std.testing.expect(first != second); const Mark = struct { pane: usize, row: i32, col: i32 }; const here = struct { fn at(pp: *Pardes) Mark { - const pane = pp.panes[pp.active].?; - return .{ .pane = pp.active, .row = pane.body.cur_row, .col = pane.body.cur_col }; + const pane = pp.panes[pp.view().active].?; + return .{ .pane = pp.view().active, .row = pane.body.cur_row, .col = pane.body.cur_col }; } }.at; lookKey(p, 'n'); @@ -805,7 +805,7 @@ test "identical result refresh keeps warm content caches without allocation" { const deallocations = allocator.deallocations; allocator.fail_index = allocator.alloc_index; defer allocator.fail_index = std.math.maxInt(usize); - p.active = id; + p.view().active = id; source.search_pane = null; source.search_row = null; p.look_walk_owner = null; @@ -830,7 +830,7 @@ test "identical result refresh keeps warm content caches without allocation" { try std.testing.expectEqual(@as(usize, 1), file.scroll); try std.testing.expectEqual(@as(i32, 3), result.hscroll); try std.testing.expectEqualStrings("after", file.output.?.arg()); - try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 0), p.view().active); try std.testing.expectEqual(id, source.search_pane.?); try std.testing.expectEqual(@as(usize, 1), source.search_row.?); try std.testing.expectEqual(result.serial, p.look_walk_owner.?); @@ -897,7 +897,7 @@ test "rejected result refresh frees incoming text and leaves the existing output try std.testing.expectEqual(free_slot, p.freeSlot()); try std.testing.expectEqual(id, source.search_pane.?); try std.testing.expectEqual(@as(usize, 1), source.search_row.?); - try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(usize, 0), p.view().active); } try std.testing.expect(allocator.has_induced_failure); } @@ -1309,7 +1309,7 @@ test "stacked search and LSP results retain source tint navigation and dump owne try std.testing.expectEqual(@as(usize, 6), marked); const number = std.mem.indexOf(u8, file.content, "42").?; try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.number), file.highlights[number]); - p.active = id; + p.view().active = id; pane.body.mode = .normal; pardes.look.armLookWalk(p, id); for ([_]struct { key: u21, match: usize }{ .{ .key = 'n', .match = 0 }, .{ .key = 'n', .match = 1 }, .{ .key = 'N', .match = 0 } }) |step| { @@ -1333,7 +1333,7 @@ test "stacked search and LSP results retain source tint navigation and dump owne try std.testing.expectEqual(before.location_end, after.location_end); try std.testing.expectEqualSlices(u8, before.colors, after.colors); } - restored.active = id; + restored.view().active = id; pardes.look.armLookWalk(restored, id); // The dot came back on the match it was on; the walk goes on // from it both ways, N wrapping to the last as it does live. |
