summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-15 16:10:48 -0300
committerGabriel Schneider <[email protected]>2026-09-15 17:24:42 -0300
commitc6ab9db0fdbcb8d16f666749194bb111218b96a8 (patch)
tree0cca62d2076ff4ed5a03c79c5edd1cb06a12ceb8 /test
parentb292808d75078c6b121e4873b150574308bcdc6f (diff)
downloadpardes-c6ab9db0fdbcb8d16f666749194bb111218b96a8.tar.gz
pardes-c6ab9db0fdbcb8d16f666749194bb111218b96a8.zip
Ignore slash-only comment markers in general Look detection
Diffstat (limited to 'test')
-rw-r--r--test/output.zig46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/output.zig b/test/output.zig
index 86ea287a..2ccd951a 100644
--- a/test/output.zig
+++ b/test/output.zig
@@ -620,6 +620,31 @@ fn selectedOutputText(pane: *const pardes.Pane) ?[]const u8 {
return line[lo..@min(line.len, hi + 1)];
}
+test "n/N in ordinary text skips comment slashes and retains real paths" {
+ if (platform == .web) return error.SkipZigTest;
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 20 });
+ defer p.deinit();
+ const pane = try p.setTestFile("// ordinary comment\n/// documentation comment\n(//) [///] punctuation\n/\n// /tmp\n//tmp\n");
+ try std.testing.expect(pane.file.?.output == null);
+ p.armLookWalk(0);
+ const available = p.freeSlot();
+ for ([_]struct { key: u21, row: i32, text: []const u8 }{
+ .{ .key = 'n', .row = 3, .text = "/" },
+ .{ .key = 'n', .row = 4, .text = "/tmp" },
+ .{ .key = 'n', .row = 5, .text = "//tmp" },
+ .{ .key = 'n', .row = 3, .text = "/" },
+ .{ .key = 'N', .row = 5, .text = "//tmp" },
+ .{ .key = 'N', .row = 4, .text = "/tmp" },
+ .{ .key = 'N', .row = 3, .text = "/" },
+ }) |step| {
+ p.update(.{ .key = .{ .cp = step.key } });
+ try std.testing.expectEqual(@as(usize, 0), p.active);
+ try std.testing.expectEqual(step.row, pane.cur_row);
+ try std.testing.expectEqualStrings(step.text, selectedOutputText(pane) orelse "");
+ try std.testing.expectEqual(available, p.freeSlot());
+ }
+}
+
test "n/N skips formatted context and selects comment match locations" {
if (!pardes.syntax.enabled) return error.SkipZigTest;
for ([_]panes.Output.Origin{ .search, .{ .query = .references } }) |origin| {
@@ -1021,3 +1046,24 @@ test "rejected result refresh frees incoming text and leaves the existing output
}
try std.testing.expect(allocator.has_induced_failure);
}
+
+test "Look ignores slash-only comment markers while retaining root and real paths" {
+ const look = pardes.look;
+ var realbuf: [4096]u8 = undefined;
+ for ([_][]const u8{ "//", "///", "////", "//:12" }) |marker| {
+ try std.testing.expect(look.resolve(null, marker, ".", &realbuf) == .none);
+ try std.testing.expectEqual(@as(?look.Span, null), look.wordSpan(null, marker, ".", &realbuf));
+ }
+ for ([_][]const u8{ "(//),", "///!" }) |marker|
+ try std.testing.expectEqual(@as(?look.Span, null), look.wordSpan(null, marker, ".", &realbuf));
+ try std.testing.expectEqual(@as(?look.Span, null), look.lineSpan(null, " // ordinary comment", ".", &realbuf));
+ if (platform == .web) return;
+ try std.testing.expect(look.resolve(null, "/", ".", &realbuf) == .dir);
+ try std.testing.expect(look.wordSpan(null, "/", ".", &realbuf) != null);
+ var pathbuf: [4096]u8 = undefined;
+ const cwd = pathbuf[0..try std.process.currentPath(std.testing.io, &pathbuf)];
+ const doubled = try std.fmt.allocPrint(std.testing.allocator, "/{s}", .{cwd});
+ defer std.testing.allocator.free(doubled);
+ try std.testing.expect(look.resolve(null, doubled, ".", &realbuf) == .dir);
+ try std.testing.expect(look.resolve(null, "https://example.com/path", ".", &realbuf) == .url);
+}