summaryrefslogtreecommitdiff
path: root/src/lsp/lsp.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-23 17:10:58 -0300
committerGabriel Schneider <[email protected]>2026-10-23 17:10:58 -0300
commit0073d05329335dbb0eb85f5c3044e42805d144e5 (patch)
tree744edfc317719b2018b1c3a8657c223aec058d47 /src/lsp/lsp.zig
parenta8b457a306a4442975210bcac3f04b56513c61c3 (diff)
downloadpardes-0073d05329335dbb0eb85f5c3044e42805d144e5.tar.gz
pardes-0073d05329335dbb0eb85f5c3044e42805d144e5.zip
Callstack lists every caller and pages a tree too big for one query; memory bounds and resident-size fixes
Callstack walks while the server answers, counts on the message row past a second, puts test callers last at each level, and ends a tree past one query's memory (memory.limits.arena.lsp_query, a 256 MiB region taken and given back per query) in a row whose Callstack shows the next page. Grep reads whole files. New hard limits: undo text per file, image decode pixels, the LSP snapshot of other open files, one paste. Safe builds no longer fill worst-case buffers with 0xAA (memory.unfilled), big regions are kept off transparent huge pages, and malloc_trim runs after big results. Also: Look's git show pages into a +Diff, and dropped marks in File. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/lsp/lsp.zig')
-rw-r--r--src/lsp/lsp.zig17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lsp/lsp.zig b/src/lsp/lsp.zig
index 4a70efe5..1c1b57a2 100644
--- a/src/lsp/lsp.zig
+++ b/src/lsp/lsp.zig
@@ -26,6 +26,10 @@ pub const Kind = enum {
};
pub const callstack_match = "@callstack-match ";
+/// The last row of a Callstack page that stopped full: `<path> <callers>`,
+/// the entry indices from the top the next page starts at (`3.0.17`), and
+/// how many callers this page holds.
+pub const callstack_more = "@callstack-more ";
pub const CallstackCorners = enum { rounded, square };
pub const callstack_default_depth: u8 = 8;
pub const callstack_max_depth: u8 = 64;
@@ -46,6 +50,9 @@ pub const Req = struct {
/// For `explain`: the query it narrates, read from `arg` (`<kind>
/// <arg>`) by `explaining`; a definition when none was asked before.
explains: Kind = .definition,
+ /// The fixed region `arena` allocates from, when it is one: a walk that
+ /// can grow (Callstack) reads how much is left and stops in time.
+ budget: ?*const std.heap.FixedBufferAllocator = null,
};
pub const Doc = struct { path: []const u8, source: [:0]const u8 };
@@ -102,18 +109,18 @@ pub fn speaks(path: []const u8) bool {
return false;
}
-pub fn query(gpa: std.mem.Allocator, arena: std.mem.Allocator, req: Req, out: *std.Io.Writer) !void {
+pub fn query(io: std.Io, gpa: std.mem.Allocator, arena: std.mem.Allocator, req: Req, out: *std.Io.Writer) !void {
if (req.kind == .status) {
try out.print("backend: {s}\n", .{backend_name});
- inline for (backends) |b| try b.query(gpa, arena, req, out);
+ inline for (backends) |b| try b.query(io, gpa, arena, req, out);
return;
}
inline for (backends) |b| {
if (b.speaks(req.path) and b.supports.contains(req.kind))
- return b.query(gpa, arena, req, out);
+ return b.query(io, gpa, arena, req, out);
}
if (req.kind == .explain and backends.len > 0)
- return backends[0].query(gpa, arena, req, out);
+ return backends[0].query(io, gpa, arena, req, out);
// Nothing asked: said why, where an empty answer would read as nothing
// found.
inline for (backends) |b| if (b.speaks(req.path))
@@ -217,6 +224,6 @@ test "a question no backend answers for a file says why rather than find nothing
var buf: [256]u8 = undefined;
var out: std.Io.Writer = .fixed(&buf);
// A file no server speaks for is answered, not left empty.
- try query(std.testing.allocator, arena.allocator(), .{ .kind = .incoming_calls, .path = "/x/notes.txt", .source = "", .offset = 0 }, &out);
+ try query(std.testing.io, std.testing.allocator, arena.allocator(), .{ .kind = .incoming_calls, .path = "/x/notes.txt", .source = "", .offset = 0 }, &out);
try std.testing.expectStringStartsWith(out.buffered(), "@none ");
}