summaryrefslogtreecommitdiff
path: root/test/behaviour/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-03 17:09:53 -0300
committerGabriel Schneider <[email protected]>2026-11-03 17:17:31 -0300
commit5cc02232d522d5cd5a453caedd1e592ca20471ea (patch)
tree034d370ad6eed53abb27f2c7ff607f8e656b17c8 /test/behaviour/panes.zig
parent37408da299e21b8807ccd10545482a709bac88c7 (diff)
downloadpardes-5cc02232d522d5cd5a453caedd1e592ca20471ea.tar.gz
pardes-5cc02232d522d5cd5a453caedd1e592ca20471ea.zip
test: eleven more of src/pardes.zig's tests through the 9P tree alone (test/behaviour/columns_and_tags, modes, tags, panes): a click past a column tag's text typing after it, a newline there a space and a long tag scrolled to its caret, Enter and Tab in a tag running the word under the cursor, Esc alternating two panes of a kind, Esc out of a column or the workspace tag, Shift-Esc out of every mode, a name typed into the tag's path pending past Esc, an unsaved file's tag its name alone, a question ended in the log when its pane closes, focus on a closed pane to the one taking its place; Session's cursor (/screen's); each checked to fail against a break (flatten keeping newlines, the header drawn unscrolled, Enter in a header a Look, Esc in normal mode not running Last, Esc in a header not leaving it, Shift-Esc leaving insert on, the first Esc on a drafted name dropping it, a dirty tag marked ' *', del_side left out of noteRetire's answer, removeColumn's focus to any pane)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/panes.zig')
-rw-r--r--test/behaviour/panes.zig63
1 files changed, 63 insertions, 0 deletions
diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig
index 01820a07..d0773bfb 100644
--- a/test/behaviour/panes.zig
+++ b/test/behaviour/panes.zig
@@ -49,3 +49,66 @@ test "panes: Putall saves every pane with unsaved edits to a file, one each, and
try s.write("/ctl", "Putall\n");
try std.testing.expectEqual(@as(usize, 1), s.saved);
}
+
+test "panes: an unsaved file's tag is its name alone, its dirty file says it is unsaved" {
+ var s = try Session.initFile(std.testing.allocator, "before\n");
+ defer s.deinit();
+ const n = try s.focused();
+ const tag = s.at("/pane/{d}/tag", .{n});
+ const clean = try s.read(tag);
+ try s.write(s.at("/pane/{d}/body", .{n}), "after\n");
+ try std.testing.expectEqualStrings(clean, try s.read(tag));
+ try std.testing.expect(std.mem.indexOf(u8, clean, " *") == null);
+ try s.expect(s.at("/pane/{d}/dirty", .{n}), "1\n");
+}
+
+test "panes: a pane closed while its question stands ends the question in the log" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try s.write("/ctl", "Placement pardes\n");
+ const top = try s.focused();
+ try s.write(s.at("/pane/{d}/exec", .{top}), "New\n");
+ const closing = try s.focused();
+ try s.write(s.at("/pane/{d}/exec", .{closing}), "New\n");
+ // A middle pane: Del from a key asks which side.
+ try s.write("/focus", s.at("{d}\n", .{closing}));
+ try s.keys(" d");
+ try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), s.at("ask {d} del k j\n", .{closing})) != null);
+ // A bare answer says what this question takes.
+ const ctl = s.at("/pane/{d}/ctl", .{closing});
+ _ = try s.refused(ctl, "answer\n");
+ try std.testing.expectEqualStrings("answer takes k j or -", s.said);
+ try s.write(ctl, "Del\n");
+ try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), s.at("answer {d} -\ndel {d}", .{ closing, closing })) != null);
+}
+
+test "panes: focus on a closed pane goes to the pane that takes its place, not the one focused before" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const left = try s.focused();
+ try s.write("/ctl", "Newcol\n");
+ try s.write(s.at("/col/{d}/ctl", .{try s.column(1)}), "New\n");
+ const right = try s.focused();
+ try s.write(s.at("/pane/{d}/exec", .{left}), "New\n");
+ const low = try s.focused();
+ // `right` was focused just before `low`, but `left` grows into `low`'s
+ // rows, so `left` gets the focus.
+ try s.write(s.at("/pane/{d}/ctl", .{low}), "Del\n");
+ try std.testing.expectEqual(left, try s.focused());
+ // Closing a pane that has no focus leaves the focus where it is.
+ try s.write(s.at("/pane/{d}/exec", .{left}), "New\n");
+ const other = try s.focused();
+ try s.write("/focus", s.at("{d}\n", .{right}));
+ try s.write(s.at("/pane/{d}/ctl", .{other}), "Del\n");
+ try std.testing.expectEqual(right, try s.focused());
+ // Delcol: the column that takes the width holds, level with the closed
+ // pane, the pane that takes its place; `right` was focused just before.
+ try s.write(s.at("/pane/{d}/exec", .{right}), "New\n");
+ const right_low = try s.focused();
+ try s.write(s.at("/pane/{d}/exec", .{left}), "New\n");
+ const left_low = try s.focused();
+ try s.write("/focus", s.at("{d}\n", .{right}));
+ try s.write("/focus", s.at("{d}\n", .{left_low}));
+ try s.write(s.at("/col/{d}/ctl", .{try s.column(0)}), "Delcol\n");
+ try std.testing.expectEqual(right_low, try s.focused());
+}