summaryrefslogtreecommitdiff
path: root/src/gui/pet.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/gui/pet.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/gui/pet.zig')
-rw-r--r--src/gui/pet.zig29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/gui/pet.zig b/src/gui/pet.zig
index a249d70f..7a13ca91 100644
--- a/src/gui/pet.zig
+++ b/src/gui/pet.zig
@@ -13,8 +13,8 @@ const hop_ticks = 8;
/// Only the trailing blank part of the global tag is eligible. The caller
/// supplies its last occupied cell, including any wide-grapheme continuation.
-pub fn lane(occupied: usize, cell_w: f32, screen_w: f32, top: f32, band_h: f32, editing: bool) ?Lane {
- if (editing or cell_w <= 0 or band_h < height + 2) return null;
+pub fn lane(occupied: usize, cell_w: f32, screen_w: f32, top: f32, band_h: f32) ?Lane {
+ if (cell_w <= 0 or band_h < height + 2) return null;
const scale = @min(3, @floor((band_h - 2) / height));
const left = @as(f32, @floatFromInt(occupied + 2)) * cell_w;
const right = screen_w - 2 * cell_w - width * scale;
@@ -32,11 +32,10 @@ pub const State = struct {
frame: u8 = 0,
rng: std.Random.DefaultPrng = undefined,
+ /// No lane (the tag's text has filled it) hides the pet but keeps
+ /// where it was and what it was doing.
pub fn sample(s: *State, kind: Kind, now_ms: u64, area: ?Lane) ?Pose {
- const region = area orelse {
- s.* = .{};
- return null;
- };
+ const region = area orelse return null;
if (kind == .off) {
s.* = .{};
return null;
@@ -142,11 +141,10 @@ pub fn pixel(kind: Kind, pose: Pose, x_in: usize, y: usize) u2 {
};
}
-test "pet stays in trailing workspace blanks and disappears during editing" {
- try std.testing.expect(lane(20, 8, 200, 0, 16, false) == null);
- try std.testing.expect(lane(3, 8, 200, 0, 16, true) == null);
- try std.testing.expect(lane(3, 8, 200, 0, 10, false) == null);
- const region = lane(3, 8, 200, 2, 20, false).?;
+test "pet stays in trailing workspace blanks, and a lost lane hides it without a reset" {
+ try std.testing.expect(lane(20, 8, 200, 0, 16) == null);
+ try std.testing.expect(lane(3, 8, 200, 0, 10) == null);
+ const region = lane(3, 8, 200, 2, 20).?;
try std.testing.expect(region.left >= 5 * 8);
var state: State = .{};
var moved = false;
@@ -159,12 +157,15 @@ test "pet stays in trailing workspace blanks and disappears during editing" {
reversed = reversed or pose.left;
}
try std.testing.expect(moved and reversed);
+ const kept = state;
try std.testing.expect(state.sample(.cat, 300000, null) == null);
+ try std.testing.expectEqual(kept.x, state.x);
+ try std.testing.expectEqual(kept.tick, state.tick);
try std.testing.expect(state.sample(.off, 300100, region) == null);
}
test "pet clock is fixed rate and sprites bounded in both directions" {
- const region = lane(1, 8, 400, 0, 16, false).?;
+ const region = lane(1, 8, 400, 0, 16).?;
var state: State = .{};
const start = state.sample(.frog, 1000, region).?;
try std.testing.expectEqualDeep(start, state.sample(.frog, 1099, region).?);
@@ -180,7 +181,7 @@ test "pet clock is fixed rate and sprites bounded in both directions" {
}
test "pet rests at random spots and the frog travels only in the air" {
- const region = lane(1, 8, 800, 0, 16, false).?;
+ const region = lane(1, 8, 800, 0, 16).?;
var state: State = .{};
var last = state.sample(.frog, 0, region).?;
var rested_midway = false;
@@ -195,7 +196,7 @@ test "pet rests at random spots and the frog travels only in the air" {
}
test "pet initial idle visibly animates without walking or leaving its tile" {
- const region = lane(1, 8, 400, 0, 16, false).?;
+ const region = lane(1, 8, 400, 0, 16).?;
for ([_]Kind{ .cat, .frog }) |kind| {
var state: State = .{};
const initial = state.sample(kind, 0, region).?;