diff options
Diffstat (limited to 'test/behaviour/edit.zig')
| -rw-r--r-- | test/behaviour/edit.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/behaviour/edit.zig b/test/behaviour/edit.zig index 3d1a731e..bfb17533 100644 --- a/test/behaviour/edit.zig +++ b/test/behaviour/edit.zig @@ -29,3 +29,19 @@ 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"); +} |
