diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 23:30:42 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:02:08 -0300 |
| commit | 74bc62f04c2b747be6122ea7d165490ae90a6f78 (patch) | |
| tree | 1fb45ce817d83b98668828180e5d033b820a1547 /src | |
| parent | e3aaae3a56a56d1147741ff9788a9f7607b9ee57 (diff) | |
| download | pardes-74bc62f04c2b747be6122ea7d165490ae90a6f78.tar.gz pardes-74bc62f04c2b747be6122ea7d165490ae90a6f78.zip | |
Output: hasFileSearch and resultsFrom go, nothing called either, and the file's tests call decorateRow with no metadata where rowDecoration wrapped that call for them
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
| -rw-r--r-- | src/Output.zig | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/src/Output.zig b/src/Output.zig index e6a468ee..3d8d713c 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -91,10 +91,6 @@ const RowDecoration = struct { } }; -fn rowDecoration(output: ?State, line: []const u8) RowDecoration { - return decorateRow(output, line, null); -} - pub fn decorateRow(output: ?State, line: []const u8, metadata: ?locations.Row) RowDecoration { const origin = (output orelse return .{}).from; const callstack = std.meta.eql(origin, Origin{ .query = .callstack }); @@ -149,40 +145,40 @@ pub fn decorateRow(output: ?State, line: []const u8, metadata: ?locations.Row) R test "callstack guides and Look locations share result decoration" { const from: State = .{ .from = .{ .query = .callstack } }; - const loc = rowDecoration(from, "└──┬ lib.rs:2:8-10 fn add() {"); + const loc = decorateRow(from, "└──┬ lib.rs:2:8-10 fn add() {", null); try std.testing.expectEqual(@as(usize, "└──┬ lib.rs:2:8-10".len), loc.location_end); try std.testing.expect(!loc.declaration); try std.testing.expect(!usesLocationsConfig(from.from)); try std.testing.expect(!traits(from.from).jumps); const call_line = " lib.rs:12:12-20 return calculate(value);"; - const call = rowDecoration(from, call_line); + const call = decorateRow(from, call_line, null); try std.testing.expectEqualStrings("calculate", call_line[call.mark_start..call.mark_end]); - const reference = rowDecoration(.{ .from = .{ .query = .references } }, call_line[4..]); + const reference = decorateRow(.{ .from = .{ .query = .references } }, call_line[4..], null); try std.testing.expectEqual(reference.mark_start + 4, call.mark_start); try std.testing.expectEqual(reference.mark_end + 4, call.mark_end); try std.testing.expectEqual(reference.location_end + 4, call.location_end); const tab_line = " tab.zig:4:9-11 \treturn run();"; - const tab_call = rowDecoration(from, tab_line); + const tab_call = decorateRow(from, tab_line, null); try std.testing.expectEqualStrings("run", tab_line[tab_call.mark_start..tab_call.mark_end]); } test "result decoration follows source byte ranges and diagnostic provenance" { - const row = rowDecoration(.{ .from = .search }, "src/a.rs:3:5-7 let abc = 1;"); + const row = decorateRow(.{ .from = .search }, "src/a.rs:3:5-7 let abc = 1;", null); try std.testing.expectEqualStrings("abc", "src/a.rs:3:5-7 let abc = 1;"[row.mark_start..row.mark_end]); - const prose = rowDecoration(.{ .from = .{ .query = .hover } }, "src/a.rs:3:5-7 error: prose"); + const prose = decorateRow(.{ .from = .{ .query = .hover } }, "src/a.rs:3:5-7 error: prose", null); try std.testing.expectEqual(@as(usize, 0), prose.mark_end); - const diagnostic = rowDecoration(.{ .from = .{ .query = .diagnostics } }, "src/a.rs:3:5-7 warning: unused"); + const diagnostic = decorateRow(.{ .from = .{ .query = .diagnostics } }, "src/a.rs:3:5-7 warning: unused", null); try std.testing.expectEqual(.warning, diagnostic.severity); try std.testing.expectEqualStrings("warning:", "src/a.rs:3:5-7 warning: unused"[diagnostic.mark_start..diagnostic.mark_end]); - const malformed = rowDecoration(.{ .from = .search }, "src/a.rs:3:99999999999999999999-99999999999999999999 text"); + const malformed = decorateRow(.{ .from = .search }, "src/a.rs:3:99999999999999999999-99999999999999999999 text", null); try std.testing.expect(malformed.mark_end <= "src/a.rs:3:99999999999999999999-99999999999999999999 text".len); const snippet = "src/a.rs:3:14-16 \t\tfoo + 界 + foo"; for ([_]lsp.Kind{ .definition, .declaration, .type_definition, .implementation, .references }) |kind| { - const occurrence = rowDecoration(.{ .from = .{ .query = kind } }, snippet); + const occurrence = decorateRow(.{ .from = .{ .query = kind } }, snippet, null); try std.testing.expectEqualStrings("foo", snippet[occurrence.mark_start..occurrence.mark_end]); } for ([_]lsp.Kind{ .document_symbols, .workspace_symbols, .completion, .incoming_calls, .outgoing_calls, .supertypes, .subtypes, .rename }) |kind| { - const label = rowDecoration(.{ .from = .{ .query = kind } }, snippet); + const label = decorateRow(.{ .from = .{ .query = kind } }, snippet, null); try std.testing.expectEqual(@as(usize, 0), label.mark_end); } } @@ -235,11 +231,11 @@ test "Lspinfo and Lspwhy fill one +Lsp in a directory" { } test "plain output does not opt into location decoration" { - const report = rowDecoration(.{ .from = .{ .cmd = .LocationsConfig } }, "LocationsConfig context:5 tscontext:on"); + const report = decorateRow(.{ .from = .{ .cmd = .LocationsConfig } }, "LocationsConfig context:5 tscontext:on", null); try std.testing.expectEqualDeep(RowDecoration{}, report); - const prose = rowDecoration(.{ .from = .{ .query = .hover } }, "src/a.rs:3:5-7 error: prose"); + const prose = decorateRow(.{ .from = .{ .query = .hover } }, "src/a.rs:3:5-7 error: prose", null); try std.testing.expectEqualDeep(RowDecoration{}, prose); - const errors = rowDecoration(.{ .from = .errors }, "src/a.rs:3:5-7 error: prose"); + const errors = decorateRow(.{ .from = .errors }, "src/a.rs:3:5-7 error: prose", null); try std.testing.expectEqualDeep(RowDecoration{}, errors); try std.testing.expect(traits(.{ .query = .completion }).locations); } @@ -317,13 +313,6 @@ pub fn grain(out: ?State) Grain { return if (tr.steps) .line else .word; } -pub fn resultsFrom(p: *Pardes, pane: *Pane, from: Origin) bool { - const rp = p.panes[pane.search_pane orelse return false] orelse return false; - const f = rp.file orelse return false; - const o = f.output orelse return false; - return std.meta.eql(o.from, from); -} - pub const Location = struct { path: []const u8, at: look.Spot, @@ -462,19 +451,6 @@ pub fn open(p: *Pardes, id: usize, dir: []const u8, from: Origin, arg: []const u return pane; } -/// Find and Grep share one +Search a directory, each run replacing what -/// the last showed, as acme reuses a directory's +Errors; a pane's own -/// search keeps a pane a pattern. -/// Whether `dir` has its Find/Grep +Search open. -pub fn hasFileSearch(p: *Pardes, dir: []const u8) bool { - for (p.panes) |slot| { - const f = (slot orelse continue).file orelse continue; - const o = f.output orelse continue; - if (fileSearch(o.from) and std.mem.eql(u8, std.fs.path.dirname(f.path) orelse "", dir)) return true; - } - return false; -} - /// Whether `from` fills its directory's one +Search, whatever filled it /// last (Find, Grep, Symbols, Diagnostics, any language server's list), /// each run replacing the last. A plain word's search (in a file or a PDF) |
