summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ninep/ctl.zig11
-rw-r--r--test/behaviour/look_and_exec.zig11
-rw-r--r--test/behaviour/other_files.zig17
3 files changed, 32 insertions, 7 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index ec7cb3bc..89549933 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2471,10 +2471,7 @@ test "/index shows a name as the log does: a newline in it is \\n, a control byt
// Its tag never carries the raw newline either.
const tag = rd(p, Node.of(serialOf(p), .tag), 0, 4096).bytes;
try testing.expect(std.mem.indexOf(u8, tag, "/tmp/two\\nlines") != null);
- // A backslash of the name's own is doubled: `\n` written in a name
- // reads back unlike a newline.
- p.setCwd(term, "/tmp/back\\nslash");
- try testing.expect(std.mem.indexOf(u8, rd(p, @backingInt(tree.TopFile.index), 0, 4096).bytes, "/tmp/back\\\\nslash") != null);
+ // A name's own backslash doubled is test/behaviour/other_files.zig's.
}
test "a column takes panes until their documented minimums fill it, not until none can be halved" {
@@ -2525,9 +2522,11 @@ test "a new file saved shows in /recent, open, while it is" {
test "/recent shows a name as /index does, a newline in it escaped" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
- p.recent.opened(p.recentGpa(), "/tmp/a\nb\\c");
+ // A backslash doubled is test/behaviour/other_files.zig's; a 9P name
+ // write cannot hold a newline.
+ p.recent.opened(p.recentGpa(), "/tmp/a\nb");
const text = rd(p, @backingInt(tree.TopFile.recent), 0, 8192).bytes;
- try testing.expect(std.mem.indexOf(u8, text, "closed /tmp/a\\nb\\\\c\n") != null);
+ try testing.expect(std.mem.indexOf(u8, text, "closed /tmp/a\\nb\n") != null);
}
test "size is monotonic: growing is never refused, and a size once taken is taken again" {
diff --git a/test/behaviour/look_and_exec.zig b/test/behaviour/look_and_exec.zig
index 2ce95354..f769d72a 100644
--- a/test/behaviour/look_and_exec.zig
+++ b/test/behaviour/look_and_exec.zig
@@ -458,7 +458,11 @@ test "look-and-exec: a look opens spaced paths and locations without editing the
try expectEqual(@as(u32, 8), (try s.range(s.at("/pane/{d}/dot", .{opened})))[0]); // line 2, column 3
// The source: its text, its undo steps and its cursor as they were.
try s.expect(s.at("/pane/{d}/body", .{source}), "source stays intact\n");
- try std.testing.expectEqualStrings(ctl[0..60], (try s.read(s.at("/pane/{d}/ctl", .{source})))[0..60]);
+ const after = try s.read(s.at("/pane/{d}/ctl", .{source}));
+ try std.testing.expectEqualStrings(ctl[0..60], after[0..60]);
+ var fields = std.mem.tokenizeScalar(u8, after, ' ');
+ for (0..8) |_| _ = fields.next();
+ try std.testing.expectEqualStrings("0", fields.next().?); // still no undo step
try expectEqual(.{ @as(u32, 3), @as(u32, 3) }, try s.range(s.at("/pane/{d}/dot", .{source})));
try s.expect("/look", s.at("{d}\n", .{opened}));
// From the root, with the source focused: the same pane, moved.
@@ -623,6 +627,8 @@ test "look-and-exec: a second LookWord list look in a directory refills its +Sea
try s.write(s.at("/pane/{d}/look", .{n}), "beta\n");
try expectEqual(@as(usize, 1), std.mem.count(u8, try s.read("/index"), "/+Search "));
try expectEqual(first, try paneNamed(&s, "/+Search"));
+ // Refilled with beta's places (columns 7-10), not alpha's.
+ try std.testing.expect(has(try s.read(s.at("/pane/{d}/body", .{first})), "words.txt:1:7-10\n"));
}
test "look-and-exec: `@pN:` looks at pane N as `a.txt:` looks at a.txt, and a line past the end is said one way, `:N` or `file:N`" {
@@ -668,6 +674,9 @@ test "look-and-exec: a builtin that fails through exec, tagexec or a column's ex
// the same record, counted.
try expectEqual(@as(usize, 3), std.mem.count(u8, log, "Unmount: no such mount zzz"));
try std.testing.expect(has(log, "mount zzz (x2)"));
+ // A control character is refused with its reason.
+ try expectEqual(@as(u16, 22), try s.refused("/exec", "Msg a\x01b\n"));
+ try std.testing.expectEqualStrings("invalid command line: it holds a control character (or DEL) other than a tab", s.said);
// A look miss: one err, no msg; the same miss again is that record counted.
try s.write("/look", "zzqqnotthere\n");
try std.testing.expect(has(try s.read("/log"), "look: no match for \"zzqqnotthere\""));
diff --git a/test/behaviour/other_files.zig b/test/behaviour/other_files.zig
index 2d5cb112..701f4f14 100644
--- a/test/behaviour/other_files.zig
+++ b/test/behaviour/other_files.zig
@@ -309,3 +309,20 @@ test "other-files: a remembered place is clamped to the file as it is now, its s
try std.testing.expectEqual(back, try s.focused());
try std.testing.expectEqual(dot, try s.range(s.at("/pane/{d}/dot", .{back})));
}
+
+test "other-files: /index and /recent show a name's own backslash doubled, so `\\n` written in a name reads back unlike a newline" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "back\\nslash", .data = "x\n" });
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const dir = try tmpPath(&s, &tmp);
+ const n = try s.focused();
+ try s.write(s.at("/pane/{d}/name", .{n}), s.at("{s}/back\\nslash\n", .{dir}));
+ const index = try s.read("/index");
+ try std.testing.expect(has(index, s.at("{s}/back\\\\nslash ", .{dir})));
+ try std.testing.expectEqual(@as(usize, 1), std.mem.count(u8, index, "\n"));
+ try s.write(s.at("/pane/{d}/exec", .{n}), "Get\n");
+ try s.write(s.at("/pane/{d}/ctl", .{n}), "Del\n");
+ try std.testing.expect(has(try s.read("/recent"), s.at("closed {s}/back\\\\nslash\n", .{dir})));
+}