summaryrefslogtreecommitdiff
path: root/src/Query.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Query.zig')
-rw-r--r--src/Query.zig27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Query.zig b/src/Query.zig
index c1a89164..4ae57691 100644
--- a/src/Query.zig
+++ b/src/Query.zig
@@ -2728,3 +2728,30 @@ test "a row's address is the shortest path a Look from the query pane resolves:
} else return error.TestUnexpectedResult;
}
}
+
+test "a query row's address reaches every way a look arrives: an empty look written back to event and the whole row written to look, as the mouse on it" {
+ if (!filesystem.platform_has_fs) return;
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 48 });
+ defer p.deinit();
+ const a = try testFileIn(p, &tmp, "a.txt", "zero\none needle\ntwo\nthree needle here\n");
+ leader(p, "fg");
+ typeKeys(p, "needle");
+ settle(p);
+ const qid = queryPane(p).?;
+ const qp = p.panes[qid].?;
+ const f = &qp.file.?;
+ const at = std.mem.indexOf(u8, f.content, "\na.txt:4:7").? + 1;
+ const line = f.content[at..std.mem.indexOfScalarPos(u8, f.content, at, '\n').?];
+ // an empty look written back, on the address: the row's address whole,
+ // its path as the row keeps it
+ try std.testing.expect(std.mem.endsWith(u8, @import("ninep/events.zig").expandAt(p, qp, f.content, at + 3, true, true), "/a.txt:4:7"));
+ // on its code: the word there
+ try std.testing.expectEqualStrings("three", @import("ninep/events.zig").expandAt(p, qp, f.content, at + line.len - "three needle here".len + 1, true, true));
+ // the whole row written to the pane's look: the place
+ a.body.cur_row = 0;
+ const tree = @import("ninep/tree.zig");
+ try std.testing.expectEqual(tree.Status.ok, @import("ninep/testing.zig").wr(p, tree.Node.of(qp.serial, .look), line).reply.status);
+ try std.testing.expectEqual(@as(i32, 3), a.body.cur_row);
+}