From 0405db5de9e78af1fd6df04d25f461e435a943ae Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 31 Oct 2026 00:46:18 -0300 Subject: Query: Enter lands on a current row only while its place is there: a frozen query pane's rows edited go with the text they were of (setContentSpan's dropped marks) while its items and current stay, and an Esc's `saved` keeps them so, so Enter indexed `location_rows` past its end, on a frozen pane's row (the test) and, in the box soak's window, on line 1 of a live one (Query.land, `index 1, len 0`: its speculated Enter, another view's SPC b b and Esc ordered otherwise than the session's); with none it is as with no current row, the keyboard to the owner Co-Authored-By: Claude Opus 5.5 --- src/Query.zig | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/Query.zig') 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(.{}); -- cgit v1.3