diff options
Diffstat (limited to 'test/behaviour/panes.zig')
| -rw-r--r-- | test/behaviour/panes.zig | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig index d0773bfb..149c8da1 100644 --- a/test/behaviour/panes.zig +++ b/test/behaviour/panes.zig @@ -112,3 +112,52 @@ test "panes: focus on a closed pane goes to the pane that takes its place, not t try s.write(s.at("/col/{d}/ctl", .{try s.column(0)}), "Delcol\n"); try std.testing.expectEqual(right_low, try s.focused()); } + +test "panes: Collapse keeps the text and folds the pane to its tag, and again restores it" { + var s = try Session.initFile(std.testing.allocator, "keep this text\n"); + defer s.deinit(); + var t = try Session.initTerm(std.testing.allocator); + defer t.deinit(); + const n = try s.focused(); + for ([_][]const u8{ + try s.read(s.at("/pane/{d}/tag", .{n})), + try s.read(s.at("/pane/{d}/tag", .{try s.newPane()})), + try t.read(t.at("/pane/{d}/tag", .{try t.focused()})), + }) |tag| try std.testing.expect(std.mem.endsWith(u8, tag, " Collapse Del")); + try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Del\n"); + const ctl = s.at("/pane/{d}/ctl", .{n}); + try s.write(ctl, "Collapse\n"); + // Folded to its tag: no text drawn, no cursor in it, the text kept. + try std.testing.expect(std.mem.indexOf(u8, try s.read(ctl), " collapsed ") != null); + try std.testing.expect(std.mem.indexOf(u8, try s.screen(), "keep this text") == null); + try std.testing.expectEqual(null, try s.cursor()); + try s.expect(s.at("/pane/{d}/body", .{n}), "keep this text\n"); + try s.expect(s.at("/pane/{d}/dirty", .{n}), "0\n"); + // Its tag still takes the keyboard, the cursor on the tag's row. + try s.keys(":"); + try std.testing.expectEqual((try s.where("/test.txt"))[1], (try s.cursor()).?[1]); + try s.write(ctl, "Collapse\n"); + try std.testing.expect(std.mem.indexOf(u8, try s.read(ctl), " collapsed ") == null); + try std.testing.expectEqual((try s.where("/test.txt"))[1] + 1, (try s.where("1 keep this text"))[1]); +} + +test "panes: a pane its whole text fits in never scrolls to keep a margin" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "f.txt", .data = "f\n" }); + var dir: [4096]u8 = undefined; + const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)]; + var s = try Session.initFile(std.testing.allocator, "one\ntwo\nthree\n"); + defer s.deinit(); + const n = try s.focused(); + // A second pane under it, as acme's placement puts one: right under the + // three lines, which leaves the file exactly three body rows. + try s.write(s.at("/pane/{d}/look", .{n}), s.at("{s}/f.txt\n", .{at})); + try s.write("/focus", s.at("{d}\n", .{n})); + try s.keys("jj"); + const top = (try s.where("/test.txt"))[1]; + try std.testing.expectEqual(top + 4, (try s.where(at[0..@min(at.len, 20)]))[1]); + // On the last line, and line 1 still the first drawn. + try std.testing.expectEqual(.{ @as(u32, 8), @as(u32, 8) }, try s.range(s.at("/pane/{d}/dot", .{n}))); + try std.testing.expectEqual(top + 1, (try s.where("1 one"))[1]); +} |
