1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
//! 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);
}
|