summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-15 15:25:11 -0300
committerGabriel Schneider <[email protected]>2026-09-15 17:24:42 -0300
commit95f41f0eccd27d2823ffd49bc6cd9bf01fadcc4e (patch)
tree2b8e2cbe71838b99460b2e86f253f32267912e18 /test
parent3327666759d47cad41d97264cd1f7b8ec64eafed (diff)
downloadpardes-95f41f0eccd27d2823ffd49bc6cd9bf01fadcc4e.tar.gz
pardes-95f41f0eccd27d2823ffd49bc6cd9bf01fadcc4e.zip
Align search and LSP context locations flush left
Diffstat (limited to 'test')
-rw-r--r--test/output.zig6
-rw-r--r--test/panes.zig32
2 files changed, 28 insertions, 10 deletions
diff --git a/test/output.zig b/test/output.zig
index 42b1ce7c..e835a474 100644
--- a/test/output.zig
+++ b/test/output.zig
@@ -287,9 +287,9 @@ test "Find sorts whole filenames and next location uses numeric columns" {
try std.testing.expectEqualStrings("x:10\nx:2\n", result.file.?.content);
try std.testing.expectEqual(@as(usize, 1), source.search_row.?);
const rows = "with space.zig:2:2-3 first\nwith space.zig:2:10-12 next\nwith space.zig:10:1 later";
- try std.testing.expectEqual(@as(usize, 1), panes.Output.nextResult(rows, "with space.zig", .{ .line = 2, .col = 3 }));
- try std.testing.expectEqual(@as(usize, 2), panes.Output.nextResult(rows, "with space.zig", .{ .line = 2, .col = 10 }));
- try std.testing.expectEqual(@as(usize, 0), panes.Output.nextResult(rows, "with space.zig", .{ .line = 10, .col = 1 }));
+ try std.testing.expectEqual(@as(usize, 1), panes.Output.nextResult(rows, &.{}, "with space.zig", .{ .line = 2, .col = 3 }));
+ try std.testing.expectEqual(@as(usize, 2), panes.Output.nextResult(rows, &.{}, "with space.zig", .{ .line = 2, .col = 10 }));
+ try std.testing.expectEqual(@as(usize, 0), panes.Output.nextResult(rows, &.{}, "with space.zig", .{ .line = 10, .col = 1 }));
}
test "result stepping reaches an unterminated last row" {
diff --git a/test/panes.zig b/test/panes.zig
index 72d83ce9..9972df84 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -2001,7 +2001,7 @@ const OutputTests = struct {
matches[count] = i;
count += 1;
} else {
- try std.testing.expect(std.mem.startsWith(u8, line, " "));
+ if (row.location_end > 0) try std.testing.expect(std.mem.startsWith(u8, line, path));
try std.testing.expect(!panes.Output.isResultRow(file, i));
try std.testing.expectEqualStrings(modal.lineSlice(source, expected_line - 1), line[row.code_start..]);
}
@@ -2069,15 +2069,15 @@ const OutputTests = struct {
try std.testing.expect(pardes.test_api.searchStep(restored, 0, -1));
try std.testing.expectEqual(matches[0], restored_source.search_row.?);
- // Once an edit invalidates source metadata, the explicit marker still
- // prevents context declarations from becoming search destinations.
+ // Editing drops source metadata. Hidden declarations remain skipped,
+ // while flush-left visible context becomes an ordinary location.
panes.File.setContent(p, file, try p.gpa.dupe(u8, file.content));
try std.testing.expectEqual(@as(usize, 0), file.location_rows.len);
pane.search_row = null;
try std.testing.expect(pardes.test_api.searchStep(p, 0, 1));
- try std.testing.expectEqual(matches[0], pane.search_row.?);
+ try std.testing.expectEqual(@as(usize, 2), pane.search_row.?);
try std.testing.expect(pardes.test_api.searchStep(p, 0, 1));
- try std.testing.expectEqual(matches[1], pane.search_row.?);
+ try std.testing.expectEqual(matches[0], pane.search_row.?);
}
test "Locations visible declarations are muted and stars count scopes rather than signature lines" {
@@ -2119,11 +2119,29 @@ const OutputTests = struct {
}
} else if (row.at.line <= 5) {
try std.testing.expect(row.declaration);
- try std.testing.expect(row.location_end > 2);
- try std.testing.expect(std.mem.startsWith(u8, line, " "));
+ try std.testing.expect(row.location_end > 0);
+ try std.testing.expect(std.mem.startsWith(u8, line, path));
+ try std.testing.expectEqualStrings(path, panes.Output.location(line).path);
}
}
try std.testing.expectEqual(@as(usize, 2), matches);
+ const next = panes.Output.nextResult(file.content, file.location_rows, path, .{ .line = 2, .col = 5 });
+ try std.testing.expectEqual(@as(usize, 7), file.location_rows[next].at.line);
+ try std.testing.expectEqual(.match, file.location_rows[next].kind);
+ const wrapped = panes.Output.nextResult(file.content, file.location_rows, path, .{ .line = 99 });
+ try std.testing.expectEqual(@as(usize, 2), file.location_rows[wrapped].at.line);
+ try p.dumpState();
+ const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?);
+ defer restored.deinit();
+ const restored_file = &restored.panes[pane.search_pane.?].?.file.?;
+ try std.testing.expectEqualStrings(file.content, restored_file.content);
+ try std.testing.expectEqual(file.location_rows.len, restored_file.location_rows.len);
+ for (file.location_rows, restored_file.location_rows) |before, after| {
+ try std.testing.expectEqual(before.kind, after.kind);
+ try std.testing.expectEqual(before.declaration, after.declaration);
+ try std.testing.expectEqual(before.location_end, after.location_end);
+ }
+ try std.testing.expectEqual(next, panes.Output.nextResult(restored_file.content, restored_file.location_rows, path, .{ .line = 2, .col = 5 }));
var frame = std.heap.ArenaAllocator.init(p.gpa);
defer frame.deinit();
result.scrollBy(-1000);