diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-24 19:59:30 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-24 19:59:30 -0300 |
| commit | 68155195b3b968682a29392bdc5e5d3ad8c9d0a6 (patch) | |
| tree | a88c10b41d6c96b75f859c6a9d40a3d7b5ecc676 /core | |
| parent | 173b0b8a4c854715e8bb697efc5c066927b7b671 (diff) | |
| download | pardes-68155195b3b968682a29392bdc5e5d3ad8c9d0a6.tar.gz pardes-68155195b3b968682a29392bdc5e5d3ad8c9d0a6.zip | |
TagState: a root struck in a pump wakes the loop for the frame that dates it (a fix on top of item 2, uqopxwqz, frozen), and the pane and behaviour tests that read the old leader: THE FAULT: a pump advances its clock before it settles its keys (Pardes.pump), so a root's key leaves its delay undated (TagState.asked) and TagState.wake left an undated root out, as nextWake leaves Del's question's: with nothing else due the loop slept until the next key and the level never showed (the process suite's find snapshot drew ` ␣ f …` after 400 ms still); a user hit it at every SPC, g, z, m, [, ], C-w and " in a terminal or a window; THE FIX: an undated root asks for the next frame (TagState.wake), whose advance dates it, then for its level's time; TEST FIRST: TagState.zig "a root struck in a pump, after its advance, wakes the loop for the next frame, which dates it, then for its level" (on uqopxwqz's wake: nextWake null after the key); the tests of the old behaviour: test/panes.zig's generated Help replaced by `Help h`, the word (SPC h ? is Help in the tag), test/behaviour/modes.zig's window mode (the pane with the keyboard shows window mode's head after its name, not its own words: looked for as `name `), test/behaviour/keys.zig's PDF (the leader's cell `␣` in the tag, not the SPC chip; a key the PDF takes still takes the leader away); behaviour-test 277 of 277 with these
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'core')
| -rw-r--r-- | core/TagState.zig | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/core/TagState.zig b/core/TagState.zig index 0a4d99a8..342c9812 100644 --- a/core/TagState.zig +++ b/core/TagState.zig @@ -232,12 +232,16 @@ pub fn dated(p: *Pardes, now_ns: u64) void { }; } -/// When a level next shows, for the loop's wake (Pardes.nextWake). +/// When a level next shows, for the loop's wake (Pardes.nextWake): a root +/// struck and not dated yet wants the next frame, whose advance dates it +/// (a pump settles its keys after its advance: a wake that waited for +/// the date would sleep until the next key, the level never shown). pub fn wake(p: *const Pardes) ?u64 { var soonest: ?u64 = null; for (p.views) |slot| if (slot) |v| { - const due = v.tag_state.due_ns; - if (due == asked or due == 0 or due <= p.clock.stepped_ns) continue; + var due = v.tag_state.due_ns; + if (due == asked) due = p.clock.stepped_ns + pardes.frame_ns; + if (due == 0 or due <= p.clock.stepped_ns) continue; soonest = if (soonest) |n| @min(n, due) else due; }; return soonest; @@ -761,3 +765,24 @@ test "C-w's level is window mode's, shown at once and kept while its keys move t try std.testing.expect(p.view().window_pick == null); try std.testing.expect(p.view().tag_state.root == null); } + +test "a root struck in a pump, after its advance, wakes the loop for the next frame, which dates it, then for its level" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 30 }); + defer p.deinit(); + _ = try p.setTestFile("one\n"); + while (p.nextEffect()) |_| {} + p.advance(5 * std.time.ns_per_s); + try std.testing.expect(p.nextWake() == null); + // The pump's order: its advance, then its keys (Pardes.pump, settle). + p.update(.{ .key = .{ .cp = ' ' } }); + const first = p.nextWake().?; + try std.testing.expectEqual(p.clock.stepped_ns + pardes.frame_ns, first); + p.advance(first); + const due = p.view().tag_state.due_ns; + try std.testing.expectEqual(first + 250 * std.time.ns_per_ms, due); + const second = p.nextWake().?; + try std.testing.expect(second >= due and second < due + pardes.frame_ns); + p.advance(second); + try std.testing.expect(shown(p, p.view())); + try std.testing.expect(p.nextWake() == null); +} |
