diff options
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/addons.zig | 2 | ||||
| -rw-r--r-- | test/behaviour/columns_and_tags.zig | 4 | ||||
| -rw-r--r-- | test/behaviour/follow.zig | 2 | ||||
| -rw-r--r-- | test/behaviour/keys.zig | 36 | ||||
| -rw-r--r-- | test/behaviour/language_servers.zig | 6 | ||||
| -rw-r--r-- | test/behaviour/look_and_exec.zig | 10 | ||||
| -rw-r--r-- | test/behaviour/modes.zig | 6 | ||||
| -rw-r--r-- | test/behaviour/other_files.zig | 10 | ||||
| -rw-r--r-- | test/behaviour/panes.zig | 4 | ||||
| -rw-r--r-- | test/behaviour/placement.zig | 15 | ||||
| -rw-r--r-- | test/behaviour/settings.zig | 2 | ||||
| -rw-r--r-- | test/behaviour/tags.zig | 30 |
12 files changed, 110 insertions, 17 deletions
diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig index 8b54de02..ce3c7b02 100644 --- a/test/behaviour/addons.zig +++ b/test/behaviour/addons.zig @@ -188,6 +188,8 @@ test "addons: the image addon opens the pictures a Look names, fitted, with the test "addons: a plumbing rule to a loaded kind opens that kind's pane; to one not loaded, or with its kind gone, the look falls through to text" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); try load(&s, Session.image_addon); var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); diff --git a/test/behaviour/columns_and_tags.zig b/test/behaviour/columns_and_tags.zig index d5820610..9abe64f4 100644 --- a/test/behaviour/columns_and_tags.zig +++ b/test/behaviour/columns_and_tags.zig @@ -22,6 +22,8 @@ test "columns-and-tags: a look after Newcol fills the empty column the keyboard const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)]; var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); // Newcol makes an empty column and gives its tag the keyboard; no pane // has it, so focus reads empty. try s.write("/ctl", "Newcol\n"); @@ -166,6 +168,8 @@ test "columns-and-tags: New is a column tag's word, in no pane's tag nor the wor test "columns-and-tags: a click past a column tag's text types after it, a newline typed there a space, and a long tag scrolls to its caret" { var s = try Session.initFile(std.testing.allocator, "body\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const tag = s.at("/col/{d}/tag", .{try s.column(0)}); // Its row, then the pane's tag: the column's stays one row. const rows = " New Term Find Grep Joincol Delcol"; diff --git a/test/behaviour/follow.zig b/test/behaviour/follow.zig index 22c1c3d5..bf0141d2 100644 --- a/test/behaviour/follow.zig +++ b/test/behaviour/follow.zig @@ -172,6 +172,8 @@ test "follow: a collapsed page is passed over: the cursor past the page before i test "follow: Unfollow leaves a twin with its own scroll and closes the chain up; Del of the head makes the next one head" { var s = try init(); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const head = try s.focused(); try s.write(s.at("/pane/{d}/exec", .{head}), "Follow\n"); const second = try newest(&s); diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index 78503dec..e02b1fa5 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -9,23 +9,27 @@ const window = "\x17"; // Ctrl-w test "keys: a prompt's entry and cancellation leave the tag, the body and its cursor as they were" { var s = try Session.initFile(std.testing.allocator, "one\ntwo\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); const tag = s.at("/pane/{d}/tag", .{n}); const dot = s.at("/pane/{d}/dot", .{n}); try s.replace(tag, " keep"); for ([_]struct { keys: []const u8, shown: []const u8 }{ - .{ .keys = "s", .shown = " /zq" }, - .{ .keys = "|", .shown = " |zq" }, - .{ .keys = alt ++ "|", .shown = " |-zq" }, - .{ .keys = "!", .shown = " !zq" }, - .{ .keys = alt ++ "!", .shown = " !+zq" }, + .{ .keys = "s", .shown = " s zq" }, + .{ .keys = "|", .shown = " | zq" }, + .{ .keys = alt ++ "|", .shown = " A-| zq" }, + .{ .keys = "!", .shown = " ! zq" }, + .{ .keys = alt ++ "!", .shown = " A-! zq" }, }) |case| { try s.write(dot, "6 6"); try s.keys(case.keys); - // The answer is typed into the prompt's own line, never the tag. + // The answer is typed into the tag's head (walk UI), shown in place + // of the tag's own text, which it never touches. try s.keys("zq"); _ = try s.where(case.shown); - try std.testing.expectEqualStrings("/test.txt keep", try s.read(tag)); + const head = try s.read(tag); + try std.testing.expect(std.mem.startsWith(u8, head, "/test.txt") and std.mem.startsWith(u8, head["/test.txt".len..], case.shown)); try s.keys("\x1b"); try std.testing.expectError(error.NotOnScreen, s.where(case.shown)); try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{n})), " mode:normal ")); @@ -56,8 +60,8 @@ test "keys: a prompt opens whatever the tag already holds" { try s.keys(key); try s.keys("zq"); _ = try s.where("zq"); - try std.testing.expectEqualStrings(full, try s.read(tag)); try s.keys("\x1b"); + try std.testing.expectEqualStrings(full, try s.read(tag)); } } @@ -108,6 +112,8 @@ test "keys: a count or a prefix a click or a change of pane cancels leaves nothi errdefer std.debug.print("\nkeys={s} gesture={s}\n", .{ typed, @tagName(gesture) }); var s = try Session.initFile(std.testing.allocator, "abcdefghij\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); try s.write("/ctl", "Newcol\n"); const other = try s.newPane(); @@ -353,6 +359,12 @@ test "keys: SPC j n from the pane a Look gave the keyboard walks back into the c try std.testing.expect(std.mem.startsWith(u8, try s.read(sel), "Theme ")); } +/// The screen as drawn, its notice row left out. +fn panesShown(s: *Session) ![]const u8 { + const shown = try s.screen(); + return shown[0 .. std.mem.lastIndexOfScalar(u8, shown, '\n') orelse shown.len]; +} + /// Screen row `row` as drawn. fn screenRow(s: *Session, row: usize) ![]const u8 { var rows = std.mem.splitScalar(u8, try s.screen(), '\n'); @@ -378,9 +390,9 @@ test "keys: a PDF in normal mode keeps : (its tag and back), SPC (a leader, canc // The leader shows its key cell in the tag at once (walk UI) until a // key the PDF takes, which takes the leader away. try s.keys(" "); - try std.testing.expect(std.mem.indexOf(u8, try s.screen(), " ␣ ") != null); + try std.testing.expect(std.mem.indexOf(u8, try panesShown(&s), " ␣ ") != null); try s.keys("!"); - try std.testing.expect(std.mem.indexOf(u8, try s.screen(), " ␣ ") == null); + try std.testing.expect(std.mem.indexOf(u8, try panesShown(&s), " ␣ ") == null); try s.keys("/"); try std.testing.expect(try s.cursor() != null); try std.testing.expectEqual(n, try s.focused()); @@ -394,9 +406,11 @@ test "keys: zz and zc put the cursor's line in the middle row of an odd view, as for (&lines, 0..) |*l, i| _ = try std.fmt.bufPrint(l, "l{d:0>2}\n", .{i}); var s = try Session.initFile(std.testing.allocator, std.mem.asBytes(&lines)); defer s.deinit(); + s.resize(80, 25); for ([_][]const u8{ "15jzz", "ztzc" }) |keys| { try s.keys(keys); - // 80x24 gives the pane 21 rows: l05 to l25, l15 the eleventh + // 80x25 gives the pane 21 rows (the notice row under it): l05 to + // l25, l15 the eleventh const top = (try s.where("l05"))[1]; try std.testing.expectEqual(top + 10, (try s.where("l15"))[1]); try std.testing.expectEqual(top + 20, (try s.where("l25"))[1]); diff --git a/test/behaviour/language_servers.zig b/test/behaviour/language_servers.zig index ab9585ed..904fcfba 100644 --- a/test/behaviour/language_servers.zig +++ b/test/behaviour/language_servers.zig @@ -200,6 +200,8 @@ test "language-servers: Symbols lists the file's definitions by name, a local's defer tmp.cleanup(); var s = try Session.initLanguage(std.testing.allocator); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const main = try open(&s, &tmp, "4:13"); try s.write(s.at("/pane/{d}/look", .{main}), s.at("{s}/lib.rs\n", .{std.fs.path.dirname(std.mem.trimEnd(u8, try s.read(s.at("/pane/{d}/name", .{main})), "\n")).?})); try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Symbols\n"); @@ -230,6 +232,8 @@ test "language-servers: what the index does not know, and a pane with unsaved ch defer tmp.cleanup(); var s = try Session.initLanguage(std.testing.allocator); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); // `mod`, which no occurrence covers: the scripted server's answer, // lib.rs's second line. const main = try open(&s, &tmp, "1:1"); @@ -249,6 +253,8 @@ test "language-servers: what the index does not know, and a pane with unsaved ch test "language-servers: a real indexer's index answers too (rust-analyzer's, test/scipfixture), and Lspinfo says what it holds" { var s = try Session.initLanguage(std.testing.allocator); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const main = try s.lookFile("test/scipfixture/main.rs:5:13"); try s.write(s.at("/pane/{d}/ctl", .{main}), "Hover\n"); try std.testing.expectEqualStrings("pub fn add(a: i32, b: i32) -> i32\n\nAdds two numbers.\n", try bodyOf(&s, "+Hover")); diff --git a/test/behaviour/look_and_exec.zig b/test/behaviour/look_and_exec.zig index 1bc4f040..a7de93cd 100644 --- a/test/behaviour/look_and_exec.zig +++ b/test/behaviour/look_and_exec.zig @@ -448,6 +448,8 @@ test "look-and-exec: a look opens spaced paths and locations without editing the try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "two words.zig", .data = "first\nsecond\nthird\n" }); var s = try Session.initFile(std.testing.allocator, "source stays intact\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const path = s.at("{s}/two words.zig", .{try tmpPath(&s, &tmp)}); const source = try s.focused(); const ctl = try s.read(s.at("/pane/{d}/ctl", .{source})); @@ -478,6 +480,8 @@ test "look-and-exec: a look opens spaced paths and locations without editing the test "look-and-exec: a look validates the whole batch before opening virtual files" { var s = try Session.initFile(std.testing.allocator, "source\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const source = try s.focused(); const look = s.at("/pane/{d}/look", .{source}); const index = try s.read("/index"); @@ -596,6 +600,8 @@ test "look-and-exec: a look line's trailing colon is dropped, and a look whose a try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a.txt", .data = "one\ntwo\nthree\n" }); var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const dir = try tmpPath(&s, &tmp); const before = lines(try s.read("/index")); // Failing addresses: nothing opened, the write still answered. @@ -617,6 +623,8 @@ test "look-and-exec: a look that misses file:/re/ names the file, and is logged try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "f.txt", .data = "alpha\n" }); var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const dir = try tmpPath(&s, &tmp); const first = try s.focused(); try s.write("/look", s.at("{s}/f.txt\n", .{dir})); @@ -631,6 +639,8 @@ test "look-and-exec: a look that goes to another pane leaves the looking pane's try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "f.txt", .data = "f one\nf two\n" }); var s = try Session.initFile(std.testing.allocator, "alpha bravo\ncharlie\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const dir = try tmpPath(&s, &tmp); const source = try s.focused(); const other = try s.newPane(); diff --git a/test/behaviour/modes.zig b/test/behaviour/modes.zig index a50cfb0e..0f7c9d26 100644 --- a/test/behaviour/modes.zig +++ b/test/behaviour/modes.zig @@ -17,6 +17,8 @@ test "modes: Esc in normal mode alternates between two panes of the same kind" { const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)]; var s = try Session.initFile(std.testing.allocator, "a\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const a = try s.focused(); try s.write("/look", s.at("{s}/b.txt\n", .{at})); const b = try s.focused(); @@ -133,6 +135,8 @@ fn outlined(s: *Session, lit: []const u8, names: []const []const u8) ![]const u8 test "modes: Ctrl-w outlines a pane, h j k l move the outline, and Enter, Esc, : or a pane's letter gives it the keyboard" { var s = try Session.initFile(std.testing.allocator, "left\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const a, const b, const c = try threePanes(&s); const names = &[_][]const u8{ "/a.txt", "/b.txt", "/c.txt" }; try s.keys("\x17"); @@ -176,6 +180,8 @@ fn listed(s: *Session, n: u32) !bool { test "modes: in window mode d deletes the outlined pane, asking k or j between two, c collapses it, and the mode stays on" { var s = try Session.initFile(std.testing.allocator, "top\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const top = try s.focused(); try s.write(s.at("/pane/{d}/exec", .{top}), "New\n"); const mid = try s.focused(); diff --git a/test/behaviour/other_files.zig b/test/behaviour/other_files.zig index bd8cbccd..b19ffa0f 100644 --- a/test/behaviour/other_files.zig +++ b/test/behaviour/other_files.zig @@ -124,6 +124,8 @@ test "other-files: a Jumplist entry is (closed) only while no pane has its file try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "b.txt", .data = "two\n" }); var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const dir = try tmpPath(&s, &tmp); try s.write("/look", s.at("{s}/a.txt\n", .{dir})); const a = try s.focused(); @@ -157,6 +159,8 @@ test "other-files: a closed file is found again: Recent and /recent list it clos try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "b.txt", .data = "bee\n" }); var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const dir = try tmpPath(&s, &tmp); const a = s.at("{s}/a.txt", .{dir}); // Opened, its dot on line 3, then closed. @@ -224,6 +228,8 @@ test "other-files: Back and Forward over a closed file's entries: one reopen is try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "c.txt", .data = "sea\n" }); var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const dir = try tmpPath(&s, &tmp); try s.write("/look", s.at("{s}/b.txt\n", .{dir})); const b = try s.focused(); @@ -285,6 +291,8 @@ test "other-files: Back over a closed file deleted since skips it, says so, and for ([_][]const u8{ "a.txt", "gone.txt", "c.txt" }) |name| try tmp.dir.writeFile(std.testing.io, .{ .sub_path = name, .data = "text\n" }); var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const dir = try tmpPath(&s, &tmp); try s.write("/look", s.at("{s}/a.txt\n", .{dir})); const a = try s.focused(); @@ -306,6 +314,8 @@ test "other-files: a remembered place is clamped to the file as it is now, its s try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "c.txt", .data = "one\ntwo\nthree\nfour\nfive\n" }); var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const dir = try tmpPath(&s, &tmp); try s.write("/look", s.at("{s}/c.txt:2\n", .{dir})); const c = try s.focused(); diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig index 4d4c812c..96bae187 100644 --- a/test/behaviour/panes.zig +++ b/test/behaviour/panes.zig @@ -170,6 +170,8 @@ test "panes: a second lock is refused until the holder unlocks or closes, and bi 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(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); const tag = s.at("/pane/{d}/tag", .{n}); const clean = try s.read(tag); @@ -265,6 +267,8 @@ test "panes: a pane its whole text fits in never scrolls to keep a margin" { 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(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); 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. diff --git a/test/behaviour/placement.zig b/test/behaviour/placement.zig index 73d69883..467afd1b 100644 --- a/test/behaviour/placement.zig +++ b/test/behaviour/placement.zig @@ -10,6 +10,8 @@ test "placement: an empty active column takes the new pane whole, a look from an const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)]; var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const first = try s.focused(); // Its tag has the keyboard: it is the active column, and stays so // when Esc gives the keyboard back. @@ -31,6 +33,8 @@ fn tagRow(s: *Session, name: []const u8) !usize { test "placement: New and 9P's new take the bottom half of the column's last pane" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); const first = try s.focused(); try s.write(s.at("/pane/{d}/exec", .{first}), "New\n"); const last = try s.focused(); @@ -69,7 +73,8 @@ test "placement: a look from a pane pane/new made after Delcol opens its file in fn spans(s: *Session, comptime n: usize, names: [n][]const u8) ![n][2]usize { var out: [n][2]usize = undefined; for (names, 0..) |name, i| out[i][0] = try tagRow(s, name); - const rows = std.mem.count(u8, try s.screen(), "\n") + 1; + // The last pane ends over the notice row. + const rows = std.mem.count(u8, try s.screen(), "\n"); for (0..n) |i| out[i][1] = (if (i + 1 < n) out[i + 1][0] else rows) - out[i][0]; return out; } @@ -82,6 +87,8 @@ test "placement: a look from a pane's text goes under its text when it has many 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(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); s.detach(); // Wide enough that a tag with the test's temporary path stays one row, // wherever the checkout is. @@ -116,6 +123,8 @@ test "placement: a look from the middle of a column splits only the pane it came const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)]; var s = try Session.initFile(std.testing.allocator, "one\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); s.detach(); try s.write("/ctl", "size 100 60\n"); const top = try s.focused(); @@ -131,8 +140,8 @@ test "placement: a look from the middle of a column splits only the pane it came const names = [_][]const u8{ "/test.txt", "/mid", "/low", "/made" }; // The top and bottom panes dragged by their boxes to two and three // rows, under a placement's minimum; the middle one full of text, so - // the one halved. - const rows = std.mem.count(u8, try s.screen(), "\n") + 1; + // the one halved. (The panes end over the notice row.) + const rows = std.mem.count(u8, try s.screen(), "\n"); const r = try spans(&s, 3, names[0..3].*); try s.write("/mousein", s.at("m 0 {d} 1\nm 0 {d} 1\nm 0 {d} 0\n", .{ r[1][0], r[0][0] + 2, r[0][0] + 2 })); try s.write("/mousein", s.at("m 0 {d} 1\nm 0 {d} 1\nm 0 {d} 0\n", .{ r[2][0], rows - 3, rows - 3 })); diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index a6e09f35..731d4c45 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -132,6 +132,8 @@ test "settings: Back and Forward written to exec keep to the focused file" { const dir = buf[0..try tmp.dir.realPath(std.testing.io, &buf)]; var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + try s.write("/ctl", "Jumps new-pane\n"); // Each a look, as a user's jumps are: b1 a1 b40 a40 b80 a80. for ([_][]const u8{ "b.txt:1", "a.txt:1", "b.txt:40", "a.txt:40", "b.txt:80", "a.txt:80" }) |place| try s.write("/look", s.at("{s}/{s}\n", .{ dir, place })); const Step = struct { []const u8, []const u8, u32 }; diff --git a/test/behaviour/tags.zig b/test/behaviour/tags.zig index 395b63c8..e4e4c04b 100644 --- a/test/behaviour/tags.zig +++ b/test/behaviour/tags.zig @@ -22,6 +22,8 @@ fn tagCol(s: *Session, path: []const u8) !usize { test "tags: s and S in a tag answer for the tag's own text; / still searches the body" { var s = try Session.initFile(std.testing.allocator, "Some body\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); try s.replace(s.at("/pane/{d}/tag", .{n}), " Save Del Snarf"); // The tag's line, its S's selected, then changed: both are the tag's. @@ -37,6 +39,8 @@ test "tags: s and S in a tag answer for the tag's own text; / still searches the test "tags: ms and md edit a tag's own text, and the text the edit made is read back whole" { var s = try Session.initFile(std.testing.allocator, "body\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); try s.keys(":miwms("); try std.testing.expectEqualStrings("/test.txt (Save) Term Collapse Follow Del", try tag(&s, n)); @@ -47,6 +51,8 @@ test "tags: ms and md edit a tag's own text, and the text the edit made is read test "tags: the keyboard reaches a tag's path, which it can select and yank but not edit" { var s = try Session.initFile(std.testing.allocator, "body\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); const before = try tag(&s, n); // `0` is the line's start, as in acme, where the name is ordinary text. @@ -73,6 +79,8 @@ test "tags: the keyboard reaches a tag's path, which it can select and yank but test "tags: a tag remembers its cursor, starts on Save, and a click moves it" { var s = try Session.initFile(std.testing.allocator, "body\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const first = try s.focused(); try s.write("/ctl", "Newcol\n"); const second = try s.newPane(); @@ -133,6 +141,8 @@ test "tags: executing a word from the tag runs it and gives the keyboard back to test "tags: a renamed path moves the tag's cursor with the text after it and a shorter tag pulls it back" { var s = try Session.initFile(std.testing.allocator, "body\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); try s.keys("::"); // on Save, and back try s.write(s.at("/pane/{d}/name", .{n}), "/界.zig"); @@ -166,6 +176,8 @@ test "tags: window keys move between panes from a tag and each tag keeps its cur test "tags: a tag's normal mode is the body's: motions stay in the tag and insert types into it" { var s = try Session.initFile(std.testing.allocator, "body\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const first = try s.focused(); try s.write("/ctl", "Newcol\n"); const right_pane = try s.newPane(); @@ -189,6 +201,8 @@ test "tags: a tag's normal mode is the body's: motions stay in the tag and inser test "tags: a tag with a newline in it is as tall as its lines, and each line is typed into and pointed at" { var s = try Session.initFile(std.testing.allocator, "body\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); // Insert mode in a tag is a body's: Enter is a new line. try s.keys(":A\nSecond"); @@ -292,6 +306,8 @@ fn clickPathEnd(s: *Session, path: []const u8) !void { test "tags: a name drafted in the tag commits with Enter, cancels with two Escs, and changes neither body nor tag text" { var s = try Session.initFile(std.testing.allocator, "original body\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); const name = s.at("/pane/{d}/name", .{n}); try s.write(s.at("/pane/{d}/tag", .{n}), " JumpTrail"); @@ -317,21 +333,25 @@ test "tags: a name drafted in the tag commits with Enter, cancels with two Escs, test "tags: a drafted name's edits are by grapheme, and an empty one is not committed" { var s = try Session.initFile(std.testing.allocator, "untouched\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); try clickPathEnd(&s, "/test.txt"); try s.keys("\x15/café界\x08"); _ = try s.where("/café Save"); try s.keys("\x08"); _ = try s.where("/caf Save"); + // (The tag, not the screen: the notice row says where the caret is.) + const tagfile = s.at("/pane/{d}/tag", .{n}); try s.keys("\x15\n"); - try std.testing.expectError(error.NotOnScreen, s.where("/test.txt")); + try std.testing.expect(std.mem.indexOf(u8, try s.read(tagfile), "/test.txt") == null); try s.expect(s.at("/pane/{d}/name", .{n}), "/test.txt\n"); try s.expect(s.at("/pane/{d}/body", .{n}), "untouched\n"); // Esc keeps the draft pending; a second drops it. try s.keys("\x1b"); - try std.testing.expectError(error.NotOnScreen, s.where("/test.txt")); + try std.testing.expect(std.mem.indexOf(u8, try s.read(tagfile), "/test.txt") == null); try s.keys("\x1b"); - _ = try s.where("/test.txt"); + try std.testing.expect(std.mem.indexOf(u8, try s.read(tagfile), "/test.txt") != null); } test "tags: leaving a pane or entering a header drops an uncommitted name" { @@ -351,6 +371,8 @@ test "tags: leaving a pane or entering a header drops an uncommitted name" { test "tags: middle clicking Save commits the drafted name before saving" { var s = try Session.initFile(std.testing.allocator, "untouched\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); try clickPathEnd(&s, "/test.txt"); try s.keys("\x15/renamed.txt"); @@ -427,6 +449,8 @@ test "tags: a pane's tag reads whole, its path first, and a write appends to its test "tags: truncating a tag clears its own text, u in the tag undoes it, and > drops the one newline ending it" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). + try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const n = try s.focused(); const path = s.at("/pane/{d}/tag", .{n}); try s.write(path, " Mine"); |
