diff options
Diffstat (limited to 'test/behaviour/edit.zig')
| -rw-r--r-- | test/behaviour/edit.zig | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/behaviour/edit.zig b/test/behaviour/edit.zig index 3d1a731e..83b1b464 100644 --- a/test/behaviour/edit.zig +++ b/test/behaviour/edit.zig @@ -29,3 +29,31 @@ test "edit: a bad command inside an Edit block written whole is named, not the } try std.testing.expect(std.mem.indexOf(u8, s.said, "z") != null); try s.expect(s.at("/pane/{d}/body", .{n}), "abc\n"); } + +test "edit: Edit through a pane's ctl renames every foo in one undo step, and a failed one changes nothing" { + var s = try Session.initFile(std.testing.allocator, "foo x foo y foo\n"); + defer s.deinit(); + const n = try s.focused(); + const ctl = s.at("/pane/{d}/ctl", .{n}); + const body = s.at("/pane/{d}/body", .{n}); + try s.write(ctl, "Edit ,x/foo/c/foobar/\n"); + try s.expect(body, "foobar x foobar y foobar\n"); + try std.testing.expectEqual(@as(u16, 5), try s.refused(ctl, "Edit ,s/nothing/x/\n")); + try std.testing.expect(std.mem.startsWith(u8, s.said, "Edit: no substitution")); + try s.expect(body, "foobar x foobar y foobar\n"); + // The whole rename is one undo step. + try s.write(ctl, "Undo"); + try s.expect(body, "foo x foo y foo\n"); +} + +test "edit: Edit's p and = never fail for want of room for +Errors: the text is logged instead" { + var s = try Session.initFile(std.testing.allocator, "one\ntwo\n"); + defer s.deinit(); + s.detach(); + try s.write("/ctl", "size 80 6\n"); + const index = try s.read("/index"); + try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Edit ,p\n"); + const log = try s.read("/log"); + try std.testing.expect(std.mem.indexOf(u8, log, " one\n") != null and std.mem.indexOf(u8, log, " two\n") != null); + try s.expect("/index", index); // the +Errors that had no room is gone +} |
