summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Query.zig29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/Query.zig b/src/Query.zig
index dfe23046..edc777f6 100644
--- a/src/Query.zig
+++ b/src/Query.zig
@@ -1866,11 +1866,15 @@ pub fn land(p: *Pardes, id: usize, row: ?usize) void {
p.active = oid;
return;
}
- const c = q.current orelse {
+ const f = &rp.file.?;
+ // A current row whose place went with its text (a frozen pane's rows
+ // edited: setContentSpan drops them, and an Esc's `saved` keeps that)
+ // is none: there is nowhere to land, as with no current one.
+ const current = if (q.current) |i| (if (i < q.items.items.len and i + 1 < f.location_rows.len) i else null) else null;
+ const c = current orelse {
if (owner_id) |oid| p.active = oid;
return;
};
- const f = &rp.file.?;
const it = q.items.items[c];
const meta = f.location_rows[c + 1];
p.jump_force = true;
@@ -2709,6 +2713,27 @@ test "B1 on a query pane's rows places the caret and selects, nothing else, the
try std.testing.expectEqual(@as(i32, 3), pane.body.cur_row);
}
+test "Enter on a frozen query pane's rows after its text was edited: no row to land on, the keyboard to its owner" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 });
+ defer p.deinit();
+ _ = try p.setTestFile("alpha\n");
+ p.newScratchBelow(0);
+ p.active = 0;
+ // SPC b b and Enter: the current row lands, the rows frozen.
+ leader(p, "bb");
+ const qid = queryPane(p).?;
+ p.update(.{ .key = .{ .cp = Key.enter } });
+ const qp = p.panes[qid].?;
+ try std.testing.expect(qp.query.?.frozen and qp.query.?.current != null);
+ // Its text edited: the rows' places go with the text they were of.
+ p.active = qid;
+ typeKeys(p, "ggjxd");
+ try std.testing.expectEqual(@as(usize, 0), qp.file.?.location_rows.len);
+ try std.testing.expect(qp.body.cur_row > 0);
+ p.update(.{ .key = .{ .cp = Key.enter } });
+ try std.testing.expectEqual(@as(usize, 0), p.active);
+}
+
test "a query row's place is its text: the match tinted after it, B3 on it opens the place, the rows saved and read again still Look" {
if (!filesystem.platform_has_fs) return;
var tmp = std.testing.tmpDir(.{});