1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
//! docs/typ/reference.typ, Edit <edit>.
const std = @import("std");
const Session = @import("session").Session;
test "edit: a write of an Edit block carries it whole, to a pane's ctl, the root's ctl and exec" {
var s = try Session.initFile(std.testing.allocator, "foo x\nfoo y\n");
defer s.deinit();
const n = try s.focused();
const body = s.at("/pane/{d}/body", .{n});
try s.write(s.at("/pane/{d}/ctl", .{n}), "Edit ,x/foo/{\ni/[/\na/]/\n}\n");
try s.expect(body, "[foo] x\n[foo] y\n");
try s.write("/ctl", "Edit ,x/\\[/{\nc/</\n}\n");
try s.expect(body, "<foo] x\n<foo] y\n");
try s.write(s.at("/pane/{d}/exec", .{n}), "Edit $a\nend\n.\n");
try s.expect(body, "<foo] x\n<foo] y\nend\n");
// A group still open when its open closes fails there, an err in the
// log, and nothing after it runs as a line.
try s.write(s.at("/pane/{d}/ctl", .{n}), "Edit ,x/foo/{\nd\n");
try s.expect(body, "<foo] x\n<foo] y\nend\n");
try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), "unmatched") != null);
}
test "edit: a bad command inside an Edit block written whole is named, not the } after it" {
var s = try Session.initFile(std.testing.allocator, "abc\n");
defer s.deinit();
const n = try s.focused();
try std.testing.expect(try s.refused(s.at("/pane/{d}/ctl", .{n}), "Edit {\n,s/a/b/\nzq\n}\n") != 0);
try std.testing.expect(std.mem.indexOf(u8, s.said, "\"}\"") == null);
try std.testing.expect(std.mem.indexOf(u8, s.said, "z") != null);
try s.expect(s.at("/pane/{d}/body", .{n}), "abc\n");
}
|