summaryrefslogtreecommitdiff
path: root/src/config.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/config.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/config.zig')
-rw-r--r--src/config.zig66
1 files changed, 19 insertions, 47 deletions
diff --git a/src/config.zig b/src/config.zig
index a92aabb6..5251b1e5 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -1230,27 +1230,12 @@ pub const Runtime = struct {
if (!state.shell.requested.set(value)) return false;
state.shell.pending = true;
},
- .tagline_size => {
- const text = std.mem.trim(u8, argument orelse return false, " \t\r\n");
- const percent = std.fmt.parseInt(u16, text, 10) catch return false;
- if (percent < tagline_percent_min or percent > tagline_percent_max) return false;
- state.font.tagline_percent = @intCast(percent);
- },
+ .tagline_size => state.font.tagline_percent = @intCast(number(u16, argument, " \t\r\n", tagline_percent_min, tagline_percent_max) orelse return false),
.window_opacity => {
- const text = std.mem.trim(u8, argument orelse return false, " \t\r\n");
- for (text) |byte| if (!std.ascii.isDigit(byte)) return false;
- const percent = std.fmt.parseInt(u8, text, 10) catch return false;
- if (percent > 100) return false;
- state.window_opacity = percent;
+ state.window_opacity = number(u8, argument, " \t\r\n", 0, 100) orelse return false;
state.window_opacity_pending = true;
},
- .window_blur => {
- const text = std.mem.trim(u8, argument orelse return false, " \t\r\n");
- for (text) |byte| if (!std.ascii.isDigit(byte)) return false;
- const percent = std.fmt.parseInt(u8, text, 10) catch return false;
- if (percent > 100) return false;
- state.window_blur = percent;
- },
+ .window_blur => state.window_blur = number(u8, argument, " \t\r\n", 0, 100) orelse return false,
// Bare, it returns to the default directory. Else an absolute or
// `~` path, to a directory there or to be made, that may be
// written: a Dump there could never be, refused now.
@@ -1264,10 +1249,7 @@ pub const Runtime = struct {
if (!state.dump_dir.set(text)) return false;
},
.message_ms => |which| {
- const text = std.mem.trim(u8, argument orelse return false, " \t\r\n");
- for (text) |byte| if (!std.ascii.isDigit(byte)) return false;
- const ms = std.fmt.parseInt(u16, text, 10) catch return false;
- if (ms > message_ms_max) return false;
+ const ms = number(u16, argument, " \t\r\n", 0, message_ms_max) orelse return false;
switch (which) {
inline else => |w| @field(state, "message_" ++ @tagName(w) ++ "_ms") = ms,
}
@@ -1330,30 +1312,10 @@ pub const Runtime = struct {
std.meta.stringToEnum(LiftStyle, text) orelse return false;
},
.motion => state.motion = stepped(animation.Motion.Flavour, state.motion, argument) orelse return false,
- .inactive_dim => {
- const text = std.mem.trim(u8, argument orelse return false, " \t\r\n%");
- const percent = std.fmt.parseInt(u8, text, 10) catch return false;
- if (percent > 100) return false;
- state.inactive_dim = percent;
- },
- .grip_width => {
- const text = std.mem.trim(u8, argument orelse return false, " \t\r\n%");
- const percent = std.fmt.parseInt(u16, text, 10) catch return false;
- if (percent < 50 or percent > 300) return false;
- state.grip_width = percent;
- },
- .callstack_depth => {
- const text = std.mem.trim(u8, argument orelse return false, " \t\r\n");
- const depth = std.fmt.parseInt(u8, text, 10) catch return false;
- if (depth < 1 or depth > @import("lsp/lsp.zig").callstack_max_depth) return false;
- state.callstack_depth = depth;
- },
- .tab => {
- const text = std.mem.trim(u8, argument orelse return false, " \t\r\n");
- const width = std.fmt.parseInt(u16, text, 10) catch return false;
- if (width < 1 or width > 16) return false;
- state.tab = width;
- },
+ .inactive_dim => state.inactive_dim = number(u8, argument, " \t\r\n%", 0, 100) orelse return false,
+ .grip_width => state.grip_width = number(u16, argument, " \t\r\n%", 50, 300) orelse return false,
+ .callstack_depth => state.callstack_depth = number(u8, argument, " \t\r\n", 1, @import("lsp/lsp.zig").callstack_max_depth) orelse return false,
+ .tab => state.tab = number(u16, argument, " \t\r\n", 1, 16) orelse return false,
.theme, .font => return false,
}
return true;
@@ -1411,6 +1373,16 @@ pub const Runtime = struct {
return all[(at + 1) % all.len];
}
+ /// A setting's number: digits only (parseInt alone takes a sign and `_`),
+ /// trimmed of `trim`, within lo..hi.
+ fn number(comptime T: type, argument: ?[]const u8, trim: []const u8, lo: T, hi: T) ?T {
+ const text = std.mem.trim(u8, argument orelse return null, trim);
+ if (text.len == 0) return null;
+ for (text) |byte| if (!std.ascii.isDigit(byte)) return null;
+ const n = std.fmt.parseInt(T, text, 10) catch return null;
+ return if (n < lo or n > hi) null else n;
+ }
+
/// What `on`, `off` or nothing after a switch word asks for: null flips
/// it, as a bare tagline word does.
fn switchedTo(argument: ?[]const u8) error{NotOnOrOff}!?bool {
@@ -2523,7 +2495,7 @@ test "CallstackDepth is bounded and keeps the last valid runtime limit" {
try std.testing.expect(Runtime.apply(&state, Runtime.find("CallstackDepth").?, value));
try std.testing.expectEqual(try std.fmt.parseInt(u8, value, 10), state.callstack_depth);
}
- for ([_][]const u8{ "0", "65", "256", "-1", "eight", "" }) |value| {
+ for ([_][]const u8{ "0", "65", "256", "-1", "+8", "1_6", "eight", "" }) |value| {
try std.testing.expect(!Runtime.apply(&state, Runtime.find("CallstackDepth").?, value));
try std.testing.expectEqual(@as(u8, 64), state.callstack_depth);
}