summaryrefslogtreecommitdiff
path: root/test/output.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/output.zig')
-rw-r--r--test/output.zig490
1 files changed, 297 insertions, 193 deletions
diff --git a/test/output.zig b/test/output.zig
index 07a1ce23..530db77c 100644
--- a/test/output.zig
+++ b/test/output.zig
@@ -61,10 +61,10 @@ test "search tint survives wrapping and theme changes while selections remain au
light_matches += 1;
}
try std.testing.expectEqual(@as(usize, 3), light_matches);
- pane.mode = .normal;
- pane.cur_row = 0;
- pane.cur_col = @intCast(std.mem.indexOf(u8, text, "abc").? + 2);
- pane.vsel = .{ .active = true, .row = 0, .col = pane.cur_col - 2, .explicit = true };
+ pane.body.mode = .normal;
+ pane.body.cur_row = 0;
+ pane.body.cur_col = @intCast(std.mem.indexOf(u8, text, "abc").? + 2);
+ pane.body.vsel = .{ .active = true, .row = 0, .col = pane.body.cur_col - 2, .explicit = true };
const selected = try p.render(frame.allocator());
for (selected.cells) |cell|
try std.testing.expect(!std.meta.eql(cell.style.bg, pardes.Color{ .rgb = p.theme().search_bg.? }));
@@ -77,7 +77,7 @@ fn outputCell(p: *Pardes, surface: *pardes.Surface, id: usize, byte: usize) *par
const line = modal.lineSlice(pane.file.?.content, 0);
const rect = p.rects[id];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane) + @as(u16, @intCast(panes.File.displayWidth(line[0..byte])));
- const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H;
+ const y = p.bodyTop(pane, rect);
return surface.at(x, y);
}
@@ -89,7 +89,7 @@ fn resultId(p: *Pardes) !usize {
}
test "output callers opt into location highlighting instead of matching prose colons" {
- for ([_]panes.Output.Origin{ .{ .cmd = .LocationsConfig }, .{ .cmd = .Config }, .{ .query = .hover } }) |origin| {
+ for ([_]panes.Output.Origin{ .{ .cmd = .LocationsConfig }, .{ .cmd = .DumpConfig }, .{ .query = .hover } }) |origin| {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 30 });
defer p.deinit();
p.locations_config.layout = .@"inline";
@@ -185,7 +185,7 @@ test "ranked choices and prose retain their supplied order" {
}
}
-test "reference Look selects the next sorted row from the captured request and keeps navigation there" {
+test "references fill the asking text's query pane: sorted under their files, the next after where it was asked current, the owner's places the refs in it" {
if (!pardes.lsp.supports.contains(.references)) return error.SkipZigTest;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
@@ -194,53 +194,49 @@ test "reference Look selects the next sorted row from the captured request and k
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "z.zig", .data = "z\n" });
var path_buf: [256]u8 = undefined;
const path = try std.fmt.bufPrint(&path_buf, ".zig-cache/tmp/{s}/m.zig", .{tmp.sub_path});
- const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 80, .rows = 24 });
+ const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 80, .rows = 40 });
defer p.deinit();
- p.locations_config.layout = .@"inline";
const source = p.panes[0].?;
const response = "m.zig:5:5-8 later\nz.zig:1:1 last-file\nm.zig:1:7-10 earlier\nm.zig:3:5-8 current\na.zig:1:1 first-file\nm.zig:4:5-8 next\n";
- const sorted = "a.zig:1:1 first-file\nm.zig:1:7-10 earlier\nm.zig:3:5-8 current\nm.zig:4:5-8 next\nm.zig:5:5-8 later\nz.zig:1:1 last-file\n";
- source.cur_row = 2;
- source.cur_col = 4;
+ source.body.cur_row = 2;
+ source.body.cur_col = 4;
p.lspRequest(0, .references, "");
const request = p.lsp_wait.?.id;
- source.cur_row = 4;
+ // the cursor moves before the answer: it is placed by where it was asked
+ source.body.cur_row = 4;
p.lspResponse(request, response);
- const rid = source.search_pane orelse return error.MissingResults;
- const results = p.panes[rid].?;
- try expectResultRows(sorted, &results.file.?);
- try std.testing.expectEqual(@as(usize, 0), p.active);
- try std.testing.expectEqual(@as(i32, 3), source.cur_row);
- try std.testing.expect(source.vsel.active);
- try std.testing.expectEqual(@as(i32, 4), @min(source.cur_col, source.vsel.col));
- try std.testing.expectEqual(@as(i32, 7), @max(source.cur_col, source.vsel.col));
- try std.testing.expectEqual(@as(i32, 3), results.cur_row);
- try std.testing.expectEqual(@as(usize, 3), source.search_row.?);
- try std.testing.expectEqual(results.serial, p.look_walk_owner.?);
- try std.testing.expectEqual(@as(i32, 3), results.look_at.?.row);
- const available = p.freeSlot();
+ const qid = panes.Query.ofOwner(p, source.serial) orelse return error.MissingResults;
+ const results = p.panes[qid].?;
+ const content = results.file.?.content;
+ try std.testing.expect(std.mem.startsWith(u8, content, "Refs \n"));
+ // under their files, in order
+ const a_at = std.mem.indexOf(u8, content, "\na.zig\n").?;
+ const m_at = std.mem.indexOf(u8, content, "\nm.zig\n").?;
+ const z_at = std.mem.indexOf(u8, content, "\nz.zig\n").?;
+ try std.testing.expect(a_at < m_at and m_at < z_at);
+ // the owner's places are its four refs; the current the one after line 3
+ try std.testing.expectEqual(@as(usize, 4), source.places.hits.items.len);
+ try std.testing.expectEqual(@as(?usize, 2), source.places.current);
+ try std.testing.expectEqual(@as(i32, 3), source.body.cur_row);
+ 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.expect(results.body.mode == .normal and results.body.cur_row > 0);
p.update(.{ .key = .{ .cp = 'n' } });
- try std.testing.expectEqual(rid, p.active);
- try std.testing.expectEqual(@as(i32, 4), results.cur_row);
- try std.testing.expectEqual(available, p.freeSlot());
+ 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(i32, 4), source.body.cur_row);
p.update(.{ .key = .{ .cp = 'N' } });
- try std.testing.expectEqual(@as(i32, 3), results.cur_row);
-
+ 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;
- source.cur_row = 4;
- source.cur_col = 4;
- p.lspRequest(0, .references, "");
- p.lspResponse(p.lsp_wait.?.id, response);
- try std.testing.expect(std.mem.endsWith(u8, p.panes[p.active].?.file.?.path, "/z.zig"));
- try std.testing.expectEqual(@as(i32, 5), results.cur_row);
- try std.testing.expectEqual(@as(usize, 5), source.search_row.?);
- const last = p.active;
- p.lspRequest(last, .references, "");
- p.lspResponse(p.lsp_wait.?.id, response);
- try std.testing.expect(std.mem.endsWith(u8, p.panes[p.active].?.file.?.path, "/a.zig"));
- const wrapped = p.panes[p.panes[last].?.search_pane.?].?;
- try std.testing.expectEqual(@as(i32, 0), wrapped.cur_row);
- try std.testing.expectEqual(wrapped.serial, p.look_walk_owner.?);
+ 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);
}
test "location sorting leaves mixed prose alone and preserves newline shape" {
@@ -280,7 +276,7 @@ test "a single language location opens the full spaced filename" {
p.lspRequest(0, .references, "");
p.lspResponse(p.lsp_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].?.cur_row);
+ try std.testing.expectEqual(@as(i32, 1), p.panes[p.active].?.body.cur_row);
for (p.panes) |slot| {
const pane = slot orelse continue;
if (pane.file) |file| try std.testing.expect(file.output == null);
@@ -316,19 +312,19 @@ test "reordered identical results preserve the selected row and warm line index"
const index = try panes.File.lineIndex(p.gpa, file);
const content = file.content.ptr;
const revision = file.revision;
- result.cur_row = 1;
- result.cur_col = 0;
- result.vsel = .{ .active = true, .explicit = true, .row = 1, .col = 9 };
- result.select = true;
- const selected = result.vsel;
+ result.body.cur_row = 1;
+ result.body.cur_col = 0;
+ result.body.vsel = .{ .active = true, .explicit = true, .row = 1, .col = 9 };
+ result.body.select = true;
+ const selected = result.body.vsel;
try panes.Output.fillResults(p, 0, "/tmp", .{ .query = .references }, "new request", try p.gpa.dupe(u8, "a.zig:10:1 second\na.zig:2:1 first\n"), 0);
try expectResultRows(sorted, file);
try std.testing.expectEqual(content, file.content.ptr);
try std.testing.expectEqual(index.ptr, file.line_starts.ptr);
try std.testing.expectEqual(revision, file.revision);
- try std.testing.expectEqual(selected, result.vsel);
- try std.testing.expect(result.select);
- try std.testing.expectEqual(@as(i32, 1), result.cur_row);
+ try std.testing.expectEqual(selected, result.body.vsel);
+ try std.testing.expect(result.body.select);
+ try std.testing.expectEqual(@as(i32, 1), result.body.cur_row);
try std.testing.expectEqual(@as(usize, 1), source.search_row.?);
}
@@ -387,10 +383,10 @@ test "result stepping reaches an unterminated last row" {
const source = try p.setTestFile("one\ntwo\n");
const rows = try std.fmt.allocPrint(p.gpa, "{s}:1:1 first\n{s}:2:1 last", .{ source.file.?.path, source.file.?.path });
try panes.Output.fillResults(p, 0, "/tmp", .search, "", rows, 0);
- try std.testing.expect(pardes.test_api.searchStep(p, 0, 1));
+ try std.testing.expect(pardes.look.searchStep(p, 0, 1));
try std.testing.expectEqual(@as(usize, 1), source.search_row.?);
const result = p.panes[source.search_pane.?].?;
- try std.testing.expectEqual(@as(i32, 1), result.cur_row);
+ try std.testing.expectEqual(@as(i32, 1), result.body.cur_row);
}
test "Mini uses OS source precedence and refreshes one independent snapshot" {
@@ -438,9 +434,9 @@ test "Mini dump preserves its exact virtual snapshot and body writes detach colo
const id = p.active;
const before = p.panes[id].?.file.?;
try std.testing.expect(before.mini != null);
- try p.dumpState();
+ try pardes.dump.dumpState(p);
panes.File.setContent(p, &source.file.?, try p.gpa.dupe(u8, "changed\n"));
- const restored = try Pardes.initFromDump(std.testing.allocator, .{ .tty_only = true }, p.dump_out.?);
+ const restored = try pardes.dump.initFromDump(std.testing.allocator, .{ .tty_only = true }, p.dump_out.?);
defer restored.deinit();
const mini = restored.panes[restored.active].?;
try std.testing.expectEqualStrings(before.content, mini.file.?.content);
@@ -472,10 +468,10 @@ test "Mini syntax colors survive toggles themes and rendering without source acc
defer p.deinit();
try p.panes[0].?.setOwnedCwd(dir);
p.settings.colors = false;
- try panes.Mini.open(p, 0, "demo.zig");
+ try panes.mini.open(p, 0, "demo.zig");
const id = p.active;
const mini = p.panes[id].?;
- const keyword = std.mem.indexOfScalar(u8, mini.file.?.mini.?.colors, @intFromEnum(pardes.syntax.Syn.keyword)) orelse return error.MissingKeywordColor;
+ 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.
p.update(.{ .resize = .{ .cols = 80, .rows = 24 } });
const position = modal.positionAt(mini.file.?.content, keyword);
@@ -490,7 +486,7 @@ test "Mini syntax colors survive toggles themes and rendering without source acc
const surface = try p.render(frame.allocator());
const rect = p.rects[id];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(mini) + @as(u16, @intCast(column));
- const y = (if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H) + @as(u16, @intCast(position.row));
+ const y = p.bodyTop(mini, rect) + @as(u16, @intCast(position.row));
if (enabled) try std.testing.expectEqualDeep(pardes.Color{ .rgb = p.theme().kw }, surface.at(x, y).style.fg);
try std.testing.expectEqual(colors, mini.file.?.mini.?.colors.ptr);
try std.testing.expectEqual(@as(usize, 0), mini.file.?.highlights.len);
@@ -522,54 +518,134 @@ test "Mini failures leave its existing snapshot and focus unchanged" {
const source = try p.setTestFile("abc\n");
var path_buf: [128]u8 = undefined;
const path = try std.fmt.bufPrint(&path_buf, "/virtual/pane/{d}/body", .{source.serial});
- try panes.Mini.open(p, 0, path);
+ try panes.mini.open(p, 0, path);
const id = p.active;
const mini = p.panes[id].?;
const body = mini.file.?.content.ptr;
const next = p.freeSlot();
- try std.testing.expectError(error.FileNotFound, panes.Mini.open(p, 0, "/virtual/does-not-exist"));
+ try std.testing.expectError(error.FileNotFound, panes.mini.open(p, 0, "/virtual/does-not-exist"));
try std.testing.expectEqual(id, p.active);
try std.testing.expectEqual(body, mini.file.?.content.ptr);
try std.testing.expectEqual(next, p.freeSlot());
}
-test "Config prints the startup path and refreshes its one output" {
+test "DumpConfig prints the startup path and refreshes its one output" {
const path = "/home/pardes-test/.config/pardes/init";
const p = try Pardes.init(std.testing.allocator, .{ .startup_config_path = path });
defer p.deinit();
- try std.testing.expect(p.executeBuiltinLine(0, "Config"));
+ try std.testing.expect(p.executeBuiltinLine(0, "DumpConfig"));
const opened = p.active;
const out = p.panes[opened].?.file.?;
for ([_][]const u8{
"Startup config: " ++ path ++ "\n",
- "Theme: orchard\n",
- "Shell requested (new panes): " ++ config.default_shell ++ " (default)\n",
- "Shell effective (last spawn): (none)\n",
- "Shell pending: on\n",
+ "Theme orchard\n",
+ "Last shell spawned: (none)\n",
+ "Shell change pending: on\n",
+ "LocationsConfig ",
}) |line| try std.testing.expect(std.mem.indexOf(u8, out.content, line) != null);
- try std.testing.expectEqualStrings(config.config_buffer, std.fs.path.basename(out.path));
- try std.testing.expectEqual(panes.Output.Origin{ .cmd = .Config }, out.output.?.from);
+ var default_line: [256]u8 = undefined;
+ try std.testing.expect(std.mem.indexOf(u8, out.content, try std.fmt.bufPrint(&default_line, "Shell {s}\n", .{config.defaultShell()})) != null);
+ try std.testing.expectEqualStrings(config.dump_config_buffer, std.fs.path.basename(out.path));
+ try std.testing.expectEqual(panes.Output.Origin{ .cmd = .DumpConfig }, out.output.?.from);
- try std.testing.expect(p.executeBuiltinLine(0, "Config"));
+ try std.testing.expect(p.executeBuiltinLine(0, "DumpConfig"));
try std.testing.expectEqual(opened, p.active);
var buffers: usize = 0;
for (p.panes) |slot| {
const f = (slot orelse continue).file orelse continue;
const origin = (f.output orelse continue).from;
- buffers += @intFromBool(std.meta.eql(origin, panes.Output.Origin{ .cmd = .Config }));
+ buffers += @intFromBool(std.meta.eql(origin, panes.Output.Origin{ .cmd = .DumpConfig }));
}
try std.testing.expectEqual(@as(usize, 1), buffers);
}
-test "Config reports the absence of a per-user config path" {
+test "DumpConfig reports the absence of a per-user config path" {
const p = try Pardes.init(std.testing.allocator, .{});
defer p.deinit();
- try std.testing.expect(p.executeBuiltinLine(0, "Config"));
+ try std.testing.expect(p.executeBuiltinLine(0, "DumpConfig"));
const report = p.panes[p.active].?.file.?.content;
try std.testing.expect(std.mem.indexOf(u8, report, "no per-user config path") != null);
}
+/// The file Config names, in a fresh temporary directory: `pardes/init`
+/// under it, written with `content` unless that is null.
+fn configFixture(tmp: *std.testing.TmpDir, content: ?[]const u8, buf: *[4096]u8) ![]const u8 {
+ if (content) |text| {
+ try tmp.dir.createDirPath(std.testing.io, "pardes");
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pardes/init", .data = text });
+ }
+ const len = try tmp.dir.realPath(std.testing.io, buf);
+ return std.fmt.bufPrint(buf[len..], "{s}/pardes/init", .{buf[0..len]}) catch unreachable;
+}
+
+test "Config opens the startup file, and a second Config goes back to its pane" {
+ if (comptime !pardes.hosted) return;
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ var buf: [4096]u8 = undefined;
+ 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;
+
+ try std.testing.expect(p.executeBuiltinLine(first, "Config"));
+ const opened = p.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;
+ try std.testing.expect(p.executeBuiltinLine(first, "Config"));
+ try std.testing.expectEqual(opened, p.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));
+ };
+ try std.testing.expectEqual(@as(usize, 1), named);
+}
+
+test "Config with no startup file opens a pane of its name, and Save makes its directory" {
+ if (comptime !pardes.hosted) return;
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ var buf: [4096]u8 = undefined;
+ 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;
+
+ try std.testing.expect(p.executeBuiltinLine(first, "Config"));
+ const opened = p.active;
+ try std.testing.expect(opened != first);
+ const f = p.panes[opened].?.file.?;
+ try std.testing.expectEqualStrings(path, f.path);
+ try std.testing.expectEqualStrings("", f.content);
+ try std.testing.expect(f.output == null);
+
+ // Again: the same pane, not a second one.
+ p.active = first;
+ try std.testing.expect(p.executeBuiltinLine(first, "Config"));
+ try std.testing.expectEqual(opened, p.active);
+
+ try std.testing.expectError(error.FileNotFound, tmp.dir.statFile(std.testing.io, "pardes", .{}));
+ // Save's effect, as a host performs it.
+ try std.testing.expect(p.executeBuiltinLine(opened, "Save"));
+ p.perform(.{ .save_file = .{ .pane = @intCast(opened) } });
+ const made = try tmp.dir.statFile(std.testing.io, "pardes", .{});
+ try std.testing.expectEqual(std.Io.File.Kind.directory, made.kind);
+}
+
+test "Config without a configuration directory says so and opens nothing" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
+ defer p.deinit();
+ const before = p.freeSlot();
+ try std.testing.expect(p.executeBuiltinLine(p.active, "Config"));
+ try std.testing.expectEqual(before, p.freeSlot());
+}
+
test "EffectCode lists readable virtual sources used by this backend" {
if (comptime !builtins.EffectCode.enabled) return;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
@@ -590,10 +666,7 @@ test "EffectCode lists readable virtual sources used by this backend" {
try std.testing.expect(std.mem.indexOf(u8, out.content, "/virtual/src/layout.zig\n") != null);
const backend_source = switch (platform) {
.tty => "/virtual/src/tty/panel_compositor.zig",
- .gui => if (@import("pardes_config").gui_shader_sources_prebuilt)
- "/virtual/shaders/prebuilt/ui.vert.glsl"
- else
- "/virtual/shaders/ui.vert.glsl",
+ .gui => "/virtual/shaders/ui.vert.glsl",
.macos => "/virtual/src/macos/Sources/ScenePostprocessor.swift",
.web, .esp32p4 => unreachable,
};
@@ -610,7 +683,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);
@@ -650,39 +723,37 @@ test "every enabled setting builtin mutates the State Config reports" {
}
}
- try std.testing.expect(p.executeBuiltinLine(p.active, "Config"));
+ try std.testing.expect(p.executeBuiltinLine(p.active, "DumpConfig"));
const report = p.panes[p.active].?.file.?.content;
for ([_][]const u8{
- "Colors: off\n",
- "Wrap: off\n",
- "Tagbottom: on\n",
- "Debug: on\n",
- "Theme: acme\n",
- "Shell requested (new panes): fish\n",
+ "Colors off\n",
+ "Wrap off\n",
+ "Tagbottom on\n",
+ "Debug on\n",
+ "Theme acme\n",
+ "Shell fish\n",
}) |line| try std.testing.expect(std.mem.indexOf(u8, report, line) != null);
- const transition = if (builtins.capabilities.panel_transitions)
- try std.fmt.bufPrint(&buf, "Panel transition: {s}\n", .{
- config.Runtime.findAction(.{ .transition = p.settings.panel_transition }).?.word,
- })
+ const transition = if (!builtins.capabilities.panel_transitions)
+ "PanelSlide unsupported\n"
+ else if (p.settings.panel_transition == .off)
+ "PanelSlide off\n"
else
- "Panel transition: unsupported\n";
+ try std.fmt.bufPrint(&buf, "{s} on\n", .{config.Runtime.findAction(.{ .transition = p.settings.panel_transition }).?.word});
try std.testing.expect(std.mem.indexOf(u8, report, transition) != null);
- const scene_status = if (builtins.capabilities.scene_shaders) "on" else "unsupported";
- for ([_][]const u8{ "Crt", "Ripple", "Glitch" }) |name| {
- const line = try std.fmt.bufPrint(&buf, "{s}: {s}\n", .{ name, scene_status });
+ // A bare word turns a bundled pass on at its default level.
+ const scene_status = if (builtins.capabilities.scene_shaders) "2" else "unsupported";
+ for ([_][]const u8{"Crt"}) |name| {
+ const line = try std.fmt.bufPrint(&buf, "{s} {s}\n", .{ name, scene_status });
try std.testing.expect(std.mem.indexOf(u8, report, line) != null);
}
const tagline = if (!builtins.capabilities.tagline_font_size)
- "TaglineSize: unsupported\n"
+ "TaglineSize unsupported\n"
else
- try std.fmt.bufPrint(&buf, "TaglineSize: {d}%{s}\n", .{
- p.settings.font.tagline_percent,
- if (builtins.capabilities.font_picker) "" else " (build-time only)",
- });
+ try std.fmt.bufPrint(&buf, "TaglineSize {d}\n", .{p.settings.font.tagline_percent});
try std.testing.expect(std.mem.indexOf(u8, report, tagline) != null);
if (chosen_font) |name| {
try std.testing.expect(std.mem.indexOf(u8, report, name) != null);
- try std.testing.expect(std.mem.indexOf(u8, report, "Font pending: on\n") != null);
+ try std.testing.expect(std.mem.indexOf(u8, report, "Font change pending: on\n") != null);
}
}
@@ -708,21 +779,21 @@ fn projectPaths(cwd_buf: *[4096]u8, path_buf: *[4096]u8) !ProjectPaths {
fn selectedOutputText(pane: *const pardes.Pane) ?[]const u8 {
const file = pane.file orelse return null;
- if (!pane.vsel.active or pane.vsel.row != pane.cur_row or pane.cur_row < 0) return null;
- const line = modal.lineSlice(file.content, @intCast(pane.cur_row));
- const lo: usize = @intCast(@max(0, @min(pane.vsel.col, pane.cur_col)));
- const hi: usize = @intCast(@max(0, @max(pane.vsel.col, pane.cur_col)));
+ if (!pane.body.vsel.active or pane.body.vsel.row != pane.body.cur_row or pane.body.cur_row < 0) return null;
+ const line = modal.lineSlice(file.content, @intCast(pane.body.cur_row));
+ const lo: usize = @intCast(@max(0, @min(pane.body.vsel.col, pane.body.cur_col)));
+ const hi: usize = @intCast(@max(0, @max(pane.body.vsel.col, pane.body.cur_col)));
if (lo >= line.len) return "";
return line[lo..@min(line.len, hi + 1)];
}
-test "n/N in ordinary text skips comment slashes and retains real paths" {
+test "LookNext/LookPrev in ordinary text skips comment slashes and retains real paths" {
if (platform == .web) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 20 });
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 = "/" },
@@ -733,15 +804,15 @@ test "n/N in ordinary text skips comment slashes and retains real paths" {
.{ .key = 'N', .row = 4, .text = "/tmp" },
.{ .key = 'N', .row = 3, .text = "/" },
}) |step| {
- p.update(.{ .key = .{ .cp = step.key } });
+ lookKey(p, step.key);
try std.testing.expectEqual(@as(usize, 0), p.active);
- try std.testing.expectEqual(step.row, pane.cur_row);
+ try std.testing.expectEqual(step.row, pane.body.cur_row);
try std.testing.expectEqualStrings(step.text, selectedOutputText(pane) orelse "");
try std.testing.expectEqual(available, p.freeSlot());
}
}
-test "n/N skips formatted context and selects comment match locations" {
+test "LookNext/LookPrev skips formatted context and selects comment match locations" {
if (!pardes.syntax.enabled) return error.SkipZigTest;
for ([_]panes.Output.Origin{ .search, .{ .query = .references } }) |origin| {
for ([_]bool{ false, true }) |tslocations| {
@@ -785,31 +856,34 @@ test "n/N skips formatted context and selects comment match locations" {
.{ .key = 'N', .match = 1 },
.{ .key = 'N', .match = 0 },
}) |step| {
- p.update(.{ .key = .{ .cp = step.key } });
+ lookKey(p, step.key);
try std.testing.expectEqual(id, p.active);
const row = matches[step.match];
- try std.testing.expectEqual(@as(i32, @intCast(row)), result.cur_row);
+ try std.testing.expectEqual(@as(i32, @intCast(row)), result.body.cur_row);
const line = modal.lineSlice(file.content, row);
try std.testing.expectEqualStrings(line[0..file.location_rows[row].location_end], selectedOutputText(result) orelse "");
try std.testing.expectEqual(available, p.freeSlot());
}
- try p.dumpState();
- const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?);
+ try pardes.dump.dumpState(p);
+ const restored = try pardes.dump.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);
- restored.update(.{ .key = .{ .cp = 'N' } });
- try std.testing.expectEqual(@as(i32, @intCast(matches[1])), restored_result.cur_row);
+ // The dot came back on the match it was on (the first), so the
+ // walk goes on from there.
+ try std.testing.expectEqual(@as(i32, @intCast(matches[0])), restored_result.body.cur_row);
+ lookKey(restored, 'n');
+ try std.testing.expectEqual(@as(i32, @intCast(matches[1])), restored_result.body.cur_row);
+ lookKey(restored, 'N');
+ try std.testing.expectEqual(@as(i32, @intCast(matches[0])), restored_result.body.cur_row);
const restored_file = &restored_result.file.?;
- const last = modal.lineSlice(restored_file.content, matches[1]);
- try std.testing.expectEqualStrings(last[0..restored_file.location_rows[matches[1]].location_end], selectedOutputText(restored_result) orelse "");
+ const last = modal.lineSlice(restored_file.content, matches[0]);
+ try std.testing.expectEqualStrings(last[0..restored_file.location_rows[matches[0]].location_end], selectedOutputText(restored_result) orelse "");
}
}
}
-test "n/N selects one output location per row and opens nothing" {
+test "LookNext/LookPrev selects one output location per row and opens nothing" {
if (platform == .web) return;
var cwd_buf: [4096]u8 = undefined;
var path_buf: [4096]u8 = undefined;
@@ -822,21 +896,21 @@ test "n/N selects one output location per row and opens nothing" {
const results = p.panes[rid].?;
const panes_before = p.freeSlot();
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(rid, p.active);
try std.testing.expectEqual(panes_before, p.freeSlot());
- try std.testing.expect(results.vsel.active and results.vsel.explicit);
+ try std.testing.expect(results.body.vsel.active and results.body.vsel.explicit);
try std.testing.expectEqualStrings("build.zig:1:1", selectedOutputText(results) orelse "");
try std.testing.expectEqual(panes.Output.Grain.line, panes.Output.grain(results.file.?.output));
- p.update(.{ .key = .{ .cp = 'n' } });
- try std.testing.expectEqual(@as(i32, 1), results.cur_row);
+ lookKey(p, 'n');
+ try std.testing.expectEqual(@as(i32, 1), results.body.cur_row);
try std.testing.expectEqualStrings("mise.toml", selectedOutputText(results) orelse "");
- p.update(.{ .key = .{ .cp = 'n' } });
- try std.testing.expectEqual(@as(i32, 3), results.cur_row); // row 2 is not look-able
+ lookKey(p, 'n');
+ try std.testing.expectEqual(@as(i32, 3), results.body.cur_row); // row 2 is not look-able
try std.testing.expectEqualStrings("uucode_config.zig:7:1", selectedOutputText(results) orelse "");
- p.update(.{ .key = .{ .cp = 'n' } });
- try std.testing.expectEqual(@as(i32, 0), results.cur_row); // ring seam
+ lookKey(p, 'n');
+ try std.testing.expectEqual(@as(i32, 0), results.body.cur_row); // ring seam
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expect(p.freeSlot() != panes_before);
@@ -844,7 +918,7 @@ test "n/N selects one output location per row and opens nothing" {
try std.testing.expectEqual(panes.Output.Grain.word, panes.Output.grain(p.panes[p.active].?.file.?.output));
}
-test "n/N resumes the result output whose Look moved focus away" {
+test "LookNext/LookPrev resumes the result output whose Look moved focus away" {
if (platform == .web) return;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
@@ -857,20 +931,21 @@ test "n/N resumes the result output whose Look moved focus away" {
const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 80, .rows = 24 });
defer p.deinit();
p.locations_config.layout = .@"inline";
+ p.settings.look_word = .list; // the +Search listing is what is walked
try std.testing.expect(p.executeBuiltinLine(0, "Look target"));
const rid = p.panes[0].?.search_pane orelse return error.MissingResults;
const results = p.panes[rid].?;
- const first = results.cur_row;
+ const first = results.body.cur_row;
try std.testing.expectEqual(@as(usize, 0), p.active);
try std.testing.expect(results.look_at != null);
try std.testing.expectEqual(results.serial, p.look_walk_owner orelse return error.MissingLookOwner);
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(rid, p.active);
- try std.testing.expectEqual(first + 1, results.cur_row);
- p.update(.{ .key = .{ .cp = 'N' } });
- try std.testing.expectEqual(first, results.cur_row);
+ try std.testing.expectEqual(first + 1, results.body.cur_row);
+ lookKey(p, 'N');
+ try std.testing.expectEqual(first, results.body.cur_row);
// A later no-match answer has no position to resume and therefore cannot
// steal the provenance established by the Look above.
@@ -886,9 +961,9 @@ test "n/N resumes the result output whose Look moved focus away" {
null,
);
try std.testing.expectEqual(owner, p.look_walk_owner.?);
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(rid, p.active);
- try std.testing.expectEqual(first + 1, results.cur_row);
+ try std.testing.expectEqual(first + 1, results.body.cur_row);
// Emptying the owner itself keeps its identity as the ring's starting
// point. Deleting it then leaves a stale serial, never an id that can bind
@@ -902,7 +977,7 @@ test "n/N resumes the result output whose Look moved focus away" {
try std.testing.expect(p.paneBySerial(owner) == null);
}
-test "N exactly reverses n across output panes and the ring seam" {
+test "LookPrev exactly reverses LookNext across output panes and the ring seam" {
if (platform == .web) return;
var cwd_buf: [4096]u8 = undefined;
var path_buf: [4096]u8 = undefined;
@@ -920,20 +995,20 @@ test "N exactly reverses n across output panes and the ring seam" {
const here = struct {
fn at(pp: *Pardes) Mark {
const pane = pp.panes[pp.active].?;
- return .{ .pane = pp.active, .row = pane.cur_row, .col = pane.cur_col };
+ return .{ .pane = pp.active, .row = pane.body.cur_row, .col = pane.body.cur_col };
}
}.at;
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
const base = here(p);
var trail: [12]Mark = undefined;
for (&trail) |*mark| {
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
mark.* = here(p);
}
var i = trail.len;
while (i > 0) {
i -= 1;
- p.update(.{ .key = .{ .cp = 'N' } });
+ lookKey(p, 'N');
const want = if (i == 0) base else trail[i - 1];
try std.testing.expectEqual(want, here(p));
}
@@ -946,45 +1021,63 @@ test "N exactly reverses n across output panes and the ring seam" {
try std.testing.expect(saw_first and saw_second);
}
-test "ThemeSel groups native themes first and skips headings in both directions" {
+test "Themes lists the ring in sections and skips headings in both directions" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 });
defer p.deinit();
const source = try p.setTestFile("notes\n");
- p.setThemeIndex(pardes.themes.len - 1);
+ pardes.colors.setThemeIndex(p, pardes.themes.len - 1);
const original_theme = p.settings.theme;
- try std.testing.expect(p.executeBuiltinLine(0, "ThemeSel"));
+ try std.testing.expect(p.executeBuiltinLine(0, "Themes"));
const tid = source.search_pane orelse return error.MissingThemeList;
const list = p.panes[tid].?;
const content = list.file.?.content;
try std.testing.expectEqual(@as(usize, 0), p.active);
- try std.testing.expectEqual(@as(i32, 0), list.cur_row);
+ try std.testing.expectEqual(@as(i32, 0), list.body.cur_row);
try std.testing.expectEqual(@as(usize, 0), list.file.?.scroll);
try std.testing.expectEqualStrings("# Pardes themes", modal.lineSlice(content, 0));
- try std.testing.expectEqualStrings("# Legacy and imported themes", modal.lineSlice(content, pardes.native_theme_count + 2));
- try std.testing.expectEqual(@as(usize, pardes.themes.len + 3), std.mem.count(u8, content, "\n"));
+ // Every theme in ring order, each section's heading after a blank line
+ // where colors.groupAt says one starts.
+ var row: usize = 1;
+ var sections: usize = 1;
+ var first_break: ?usize = null;
for (pardes.themes, 0..) |theme, i| {
- const row = i + 1 + @as(usize, if (i >= pardes.native_theme_count) 2 else 0);
+ if (i > 0) if (pardes.colors.groupAt(i)) |title| {
+ try std.testing.expectEqualStrings("", modal.lineSlice(content, row));
+ try std.testing.expect(std.mem.startsWith(u8, modal.lineSlice(content, row + 1), "# "));
+ try std.testing.expectEqualStrings(title, modal.lineSlice(content, row + 1)["# ".len..]);
+ row += 2;
+ sections += 1;
+ if (first_break == null) first_break = i;
+ };
const line = modal.lineSlice(content, row);
try std.testing.expect(std.mem.startsWith(u8, line, "Theme "));
try std.testing.expectEqualStrings(theme.name, line["Theme ".len..]);
+ row += 1;
}
+ try std.testing.expectEqual(pardes.themes.len + 1 + 2 * (sections - 1), std.mem.count(u8, content, "\n"));
+ // acme is a current theme: it is listed before any break.
+ const acme = for (pardes.themes, 0..) |t, i| {
+ if (std.mem.eql(u8, t.name, "acme")) break i;
+ } else return error.MissingAcme;
+ const brk = first_break orelse return error.NoSections;
+ try std.testing.expect(acme < brk);
// Opening an imported theme's selector must still begin with the natives.
// Walk across the section break without selecting or executing a heading.
- for (pardes.themes[0 .. pardes.native_theme_count + 1]) |theme| {
- p.update(.{ .key = .{ .cp = 'n' } });
+ for (pardes.themes[0 .. brk + 1]) |theme| {
+ lookKey(p, 'n');
try std.testing.expectEqual(tid, p.active);
- const selected = selectedOutputText(list) orelse return error.MissingThemeSelection;
+ const selected = selectedOutputText(list) orelse return error.MissingThemeSection;
try std.testing.expectEqualStrings(theme.name, selected["Theme ".len..]);
try std.testing.expectEqual(original_theme, p.settings.theme);
}
- p.update(.{ .key = .{ .cp = 'N' } });
- const previous = selectedOutputText(list) orelse return error.MissingThemeSelection;
- try std.testing.expectEqualStrings(pardes.themes[pardes.native_theme_count - 1].name, previous["Theme ".len..]);
+ lookKey(p, 'N');
+ const previous = selectedOutputText(list) orelse return error.MissingThemeSection;
+ try std.testing.expectEqualStrings(pardes.themes[brk - 1].name, previous["Theme ".len..]);
p.update(.{ .key = .{ .cp = Key.tab } });
- try std.testing.expectEqual(pardes.native_theme_count - 1, p.settings.theme);
+ try std.testing.expectEqual(brk - 1, p.settings.theme);
}
-test "n/N selects command outputs by whole row" {
+test "LookNext/LookPrev selects command outputs by whole row" {
if (platform == .web) return;
var cwd_buf: [4096]u8 = undefined;
var path_buf: [4096]u8 = undefined;
@@ -993,22 +1086,22 @@ test "n/N selects command outputs by whole row" {
defer p.deinit();
p.update(.{ .resize = .{ .cols = 100, .rows = 40 } });
- try std.testing.expect(p.executeBuiltinLine(p.active, "ThemeSel"));
+ try std.testing.expect(p.executeBuiltinLine(p.active, "Themes"));
const tid = p.panes[p.active].?.search_pane orelse return error.MissingThemeList;
const themes = p.panes[tid].?;
try std.testing.expect(panes.Output.fileTraits(themes.file.?.output).commands);
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
const row0 = std.mem.trimEnd(u8, modal.lineSlice(themes.file.?.content, 1), " \t\r");
try std.testing.expectEqualStrings(row0, selectedOutputText(themes) orelse "");
const theme_before = p.settings.theme;
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
p.update(.{ .key = .{ .cp = Key.tab } });
try std.testing.expect(p.settings.theme != theme_before);
try std.testing.expect(p.executeBuiltinLine(0, "Look build.zig"));
p.update(.tick);
try std.testing.expect(p.active != 0);
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(@as(usize, 0), p.active);
}
@@ -1024,10 +1117,10 @@ test "identical result refresh keeps warm content caches without allocation" {
const id = source.search_pane orelse return error.MissingResults;
const result = p.panes[id].?;
const file = &result.file.?;
- result.cur_row = 1;
- result.cur_col = 12;
- result.vsel = .{ .active = true, .explicit = true, .row = 0, .col = 2 };
- result.select = true;
+ result.body.cur_row = 1;
+ result.body.cur_col = 12;
+ result.body.vsel = .{ .active = true, .explicit = true, .row = 0, .col = 2 };
+ result.body.select = true;
file.scroll = 1;
result.hscroll = 3;
panes.File.refreshHighlights(p);
@@ -1040,7 +1133,7 @@ test "identical result refresh keeps warm content caches without allocation" {
const body_ptr = file.content.ptr;
const style_ptr = file.highlights.ptr;
const highlight_start = file.highlight_start;
- const selected = result.vsel;
+ const selected = result.body.vsel;
const event_node = pardes.ctlfs.Node.of(result.serial, .event);
const opened = pardes.ctlfs.handle(p, .{ .tag = 0, .op = .open, .node = event_node });
try std.testing.expectEqual(.ok, opened.status);
@@ -1071,10 +1164,10 @@ test "identical result refresh keeps warm content caches without allocation" {
try std.testing.expectEqual(freed + text.len, allocator.freed_bytes);
try std.testing.expectEqual(deallocations + 1, allocator.deallocations);
try std.testing.expect(!allocator.has_induced_failure);
- try std.testing.expectEqual(selected, result.vsel);
- try std.testing.expect(result.select);
- try std.testing.expectEqual(@as(i32, 1), result.cur_row);
- try std.testing.expectEqual(@as(i32, 12), result.cur_col);
+ try std.testing.expectEqual(selected, result.body.vsel);
+ try std.testing.expect(result.body.select);
+ try std.testing.expectEqual(@as(i32, 1), result.body.cur_row);
+ try std.testing.expectEqual(@as(i32, 12), result.body.cur_col);
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());
@@ -1082,23 +1175,24 @@ test "identical result refresh keeps warm content caches without allocation" {
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.?);
- try std.testing.expect(p.fs.panes[id].events.empty());
+ try std.testing.expect(p.panes[id].?.fs.events.empty());
}
try panes.Output.fillResults(p, 0, "/tmp", .{ .query = .references }, "changed", try p.gpa.dupe(u8, "short\n"), null);
try std.testing.expectEqual(revision + 1, file.revision);
try std.testing.expectEqualStrings("short\n", file.content);
try std.testing.expectEqualStrings("changed", file.output.?.arg());
- try std.testing.expectEqual(@as(usize, 0), file.line_starts.len);
+ // The warm index is carried through the edit, not dropped.
+ try std.testing.expectEqualSlices(usize, &.{ 0, 6 }, file.line_starts);
try std.testing.expectEqual(@as(usize, 0), file.highlights.len);
try std.testing.expect(file.syntax_dirty);
- try std.testing.expect(!result.vsel.active and !result.select);
- try std.testing.expectEqual(@as(i32, 0), result.cur_row);
- try std.testing.expectEqual(@as(i32, 0), result.cur_col);
+ try std.testing.expect(!result.body.vsel.active and !result.body.select);
+ try std.testing.expectEqual(@as(i32, 0), result.body.cur_row);
+ try std.testing.expectEqual(@as(i32, 0), result.body.cur_col);
try std.testing.expectEqual(@as(usize, 0), file.scroll);
try std.testing.expectEqual(@as(i32, 0), result.hscroll);
try std.testing.expect(source.search_row == null);
- const events = &p.fs.panes[id].events;
+ const events = &p.panes[id].?.fs.events;
try std.testing.expect(std.mem.startsWith(u8, events.peek().?, "KD"));
events.pop();
try std.testing.expect(std.mem.startsWith(u8, events.peek().?, "KI"));
@@ -1210,15 +1304,15 @@ test "result alignment chunks keep seventeen matches independent and refresh sta
const content = file.content.ptr;
const revision = file.revision;
const index = try panes.File.lineIndex(p.gpa, file);
- result.cur_row = 8;
- result.cur_col = @intCast(file.location_rows[8].code_start);
+ result.body.cur_row = 8;
+ result.body.cur_col = @intCast(file.location_rows[8].code_start);
try panes.Output.fillResults(p, 0, "/", origin, "chunks", try p.gpa.dupe(u8, input.items), 8);
try std.testing.expectEqual(result_id, source.search_pane.?);
try std.testing.expectEqual(content, file.content.ptr);
try std.testing.expectEqual(revision, file.revision);
try std.testing.expectEqual(index.ptr, file.line_starts.ptr);
try std.testing.expectEqual(@as(usize, 8), source.search_row.?);
- try std.testing.expectEqual(@as(i32, 8), result.cur_row);
+ try std.testing.expectEqual(@as(i32, 8), result.body.cur_row);
for (file.location_rows, starts) |row, start| try std.testing.expectEqual(start, row.code_start);
// Simulate a restored view made by the previous global-padding
@@ -1558,19 +1652,19 @@ 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(@intFromEnum(pardes.syntax.Syn.number), file.highlights[number]);
+ try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.number), file.highlights[number]);
p.active = id;
- pane.mode = .normal;
- p.armLookWalk(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| {
- p.update(.{ .key = .{ .cp = step.key } });
- try std.testing.expectEqual(@as(i32, @intCast(matches[step.match])), pane.cur_row);
+ lookKey(p, step.key);
+ try std.testing.expectEqual(@as(i32, @intCast(matches[step.match])), pane.body.cur_row);
const row = file.location_rows[matches[step.match]];
const line = modal.lineSlice(file.content, matches[step.match]);
try std.testing.expectEqualStrings(line[0..row.location_end], selectedOutputText(pane) orelse "");
}
- try p.dumpState();
- const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?);
+ try pardes.dump.dumpState(p);
+ const restored = try pardes.dump.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?);
defer restored.deinit();
const restored_file = &restored.panes[id].?.file.?;
try std.testing.expectEqualStrings(file.content, restored_file.content);
@@ -1584,9 +1678,14 @@ 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);
- restored.update(.{ .key = .{ .cp = 'N' } });
- try std.testing.expectEqual(@as(i32, @intCast(matches[1])), restored.panes[id].?.cur_row);
+ 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.
+ try std.testing.expectEqual(@as(i32, @intCast(matches[0])), restored.panes[id].?.body.cur_row);
+ lookKey(restored, 'N');
+ try std.testing.expectEqual(@as(i32, @intCast(matches[1])), restored.panes[id].?.body.cur_row);
+ lookKey(restored, 'n');
+ try std.testing.expectEqual(@as(i32, @intCast(matches[0])), restored.panes[id].?.body.cur_row);
try std.testing.expectEqualStrings(source_text, source.file.?.content);
}
}
@@ -1712,7 +1811,7 @@ test "location cache eviction retains early colors and honors disk and unsaved r
return error.MissingEarlyContext;
}
};
- try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.comment), try Color.valueColor(file));
+ try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.comment), try Color.valueColor(file));
const single = "f00.c:4:1-6 needle();\n";
// Put the evicted file back before a same-size edit tests exact-byte keys.
try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, single), null);
@@ -1720,13 +1819,18 @@ test "location cache eviction retains early colors and honors disk and unsaved r
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "f00.c", .data = code });
try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, single), null);
try std.testing.expect(p.locations_cache.analyses > analyses);
- try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.number), try Color.valueColor(file));
+ try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.number), try Color.valueColor(file));
// An open buffer has priority over that disk revision, even with equal size.
p.gpa.free(source.file.?.path);
source.file.?.path = try std.fs.path.join(p.gpa, &.{ dir, "f00.c" });
panes.File.setContent(p, &source.file.?, try p.gpa.dupe(u8, comment));
try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, single), null);
- try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.comment), try Color.valueColor(file));
+ try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.comment), try Color.valueColor(file));
try std.testing.expectEqualStrings(comment, source.file.?.content);
}
+
+fn lookKey(p: *Pardes, key: u21) void {
+ for ([_]u21{ ' ', 'j', if (key == 'N') 'p' else 'n' }) |cp|
+ p.update(.{ .key = .{ .cp = cp } });
+}