diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-24 11:57:26 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-24 11:57:35 -0300 |
| commit | 51903dd947f90381d1a908c488a019289a1c8413 (patch) | |
| tree | ab5b2574642493c60476e6e9bcd7cc0e1c5e8d9e /test | |
| parent | 18d89dcedaed1f8437799621675e88ca47d7cdc1 (diff) | |
| download | pardes-51903dd947f90381d1a908c488a019289a1c8413.tar.gz pardes-51903dd947f90381d1a908c488a019289a1c8413.zip | |
Search converge 3/6: the query pane, line 1 the query and its first word the source, rows made live like Callstack's, the owner's places showing the set, a +Preview promoted in place, Enter freezes, Esc restores
Diffstat (limited to 'test')
| -rw-r--r-- | test/output.zig | 59 |
1 files changed, 22 insertions, 37 deletions
diff --git a/test/output.zig b/test/output.zig index 523e8129..8ba2f357 100644 --- a/test/output.zig +++ b/test/output.zig @@ -185,7 +185,7 @@ test "ranked choices and prose retain their supplied order" { } } -test "reference Look selects the next sorted row from the captured request and keeps navigation there" { +test "references fill the asking text's query pane: sorted under their files, the next after where it was asked current, the owner's places the refs in it" { if (!pardes.lsp.supports.contains(.references)) return error.SkipZigTest; var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); @@ -194,53 +194,38 @@ test "reference Look selects the next sorted row from the captured request and k try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "z.zig", .data = "z\n" }); var path_buf: [256]u8 = undefined; const path = try std.fmt.bufPrint(&path_buf, ".zig-cache/tmp/{s}/m.zig", .{tmp.sub_path}); - const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 80, .rows = 24 }); + const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 80, .rows = 40 }); defer p.deinit(); - p.locations_config.layout = .@"inline"; const source = p.panes[0].?; const response = "m.zig:5:5-8 later\nz.zig:1:1 last-file\nm.zig:1:7-10 earlier\nm.zig:3:5-8 current\na.zig:1:1 first-file\nm.zig:4:5-8 next\n"; - const sorted = "a.zig:1:1 first-file\nm.zig:1:7-10 earlier\nm.zig:3:5-8 current\nm.zig:4:5-8 next\nm.zig:5:5-8 later\nz.zig:1:1 last-file\n"; source.body.cur_row = 2; source.body.cur_col = 4; p.lspRequest(0, .references, ""); const request = p.lsp_wait.?.id; + // the cursor moves before the answer: it is placed by where it was asked source.body.cur_row = 4; p.lspResponse(request, response); - const rid = source.search_pane orelse return error.MissingResults; - const results = p.panes[rid].?; - try expectResultRows(sorted, &results.file.?); - try std.testing.expectEqual(@as(usize, 0), p.active); + const qid = panes.Query.ofOwner(p, source.serial) orelse return error.MissingResults; + const results = p.panes[qid].?; + const content = results.file.?.content; + try std.testing.expect(std.mem.startsWith(u8, content, "Refs \n")); + // under their files, in order + const a_at = std.mem.indexOf(u8, content, "\na.zig\n").?; + const m_at = std.mem.indexOf(u8, content, "\nm.zig\n").?; + const z_at = std.mem.indexOf(u8, content, "\nz.zig\n").?; + try std.testing.expect(a_at < m_at and m_at < z_at); + // the owner's places are its four refs; the current the one after line 3 + try std.testing.expectEqual(@as(usize, 4), source.places.hits.items.len); + try std.testing.expectEqual(@as(?usize, 2), source.places.current); try std.testing.expectEqual(@as(i32, 3), source.body.cur_row); - try std.testing.expect(source.body.vsel.active); - try std.testing.expectEqual(@as(i32, 4), @min(source.body.cur_col, source.body.vsel.col)); - try std.testing.expectEqual(@as(i32, 7), @max(source.body.cur_col, source.body.vsel.col)); - try std.testing.expectEqual(@as(i32, 3), results.body.cur_row); - try std.testing.expectEqual(@as(usize, 3), source.search_row.?); - try std.testing.expectEqual(results.serial, p.look_walk_owner.?); - try std.testing.expectEqual(@as(i32, 3), results.look_at.?.row); - const available = p.freeSlot(); - lookKey(p, 'n'); - try std.testing.expectEqual(rid, p.active); - try std.testing.expectEqual(@as(i32, 4), results.body.cur_row); - try std.testing.expectEqual(available, p.freeSlot()); - lookKey(p, 'N'); - try std.testing.expectEqual(@as(i32, 3), results.body.cur_row); - + try std.testing.expectEqual(@as(usize, 6), results.query.?.total); + // n in the owner steps them, round the end without a word p.active = 0; - source.body.cur_row = 4; - source.body.cur_col = 4; - p.lspRequest(0, .references, ""); - p.lspResponse(p.lsp_wait.?.id, response); - try std.testing.expect(std.mem.endsWith(u8, p.panes[p.active].?.file.?.path, "/z.zig")); - try std.testing.expectEqual(@as(i32, 5), results.body.cur_row); - try std.testing.expectEqual(@as(usize, 5), source.search_row.?); - const last = p.active; - p.lspRequest(last, .references, ""); - p.lspResponse(p.lsp_wait.?.id, response); - try std.testing.expect(std.mem.endsWith(u8, p.panes[p.active].?.file.?.path, "/a.zig")); - const wrapped = p.panes[p.panes[last].?.search_pane.?].?; - try std.testing.expectEqual(@as(i32, 0), wrapped.body.cur_row); - try std.testing.expectEqual(wrapped.serial, p.look_walk_owner.?); + p.update(.{ .key = .{ .cp = 'n' } }); + try std.testing.expectEqual(@as(?usize, 3), source.places.current); + p.update(.{ .key = .{ .cp = 'n' } }); + try std.testing.expectEqual(@as(?usize, 0), source.places.current); + try std.testing.expectEqual(@as(usize, 0), p.active); } test "location sorting leaves mixed prose alone and preserves newline shape" { |
