summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 22:35:45 -0300
committerGabriel Schneider <[email protected]>2026-11-24 22:39:59 -0300
commit1dd5ae7a37588c42ae4b612deb767847b8a5a020 (patch)
treed6cfb4216b30c1325626585993b508b1dee00f61
parentbba7752a55bd51e87e9f11231428e369553787da (diff)
parent8c083912002f5cfdf268ed45ec217fbd8bde41d0 (diff)
downloadpardes-1dd5ae7a37588c42ae4b612deb767847b8a5a020.tar.gz
pardes-1dd5ae7a37588c42ae4b612deb767847b8a5a020.zip
walk UI M2: A2's xqqlroux merged in (TagState.loaded from dump.zig afterLoad: a loaded tag state that indexes past what it names is at rest; Core.reportFocus asks no pane past MAX_PANES), no conflict; tui core-test 1032/1201 (169 skipped, 0 failed)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--core/Core.zig3
-rw-r--r--core/TagState.zig42
-rw-r--r--core/dump.zig1
3 files changed, 45 insertions, 1 deletions
diff --git a/core/Core.zig b/core/Core.zig
index 296f4159..e8b5c024 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -1037,7 +1037,8 @@ fn reportFocus(p: *Pardes) void {
// program hears of it a round trip later (a write there would stop the
// speculation: pty_write is `keeps_stopping`'s).
if (p.tape.speculating) return;
- if (v.focus_told) |old| if (p.panes[old.id]) |pane| {
+ // A damaged dump's pane past the slots names none.
+ if (v.focus_told) |old| if (old.id < MAX_PANES) if (p.panes[old.id]) |pane| {
if (pane.serial == old.serial and pardes.Term.modes(pane.terminal).focus) p.emitWrite(old.id, "\x1b[O");
};
if (want) |new| if (pardes.Term.modes(p.panes[new.id].?.terminal).focus) p.emitWrite(new.id, "\x1b[I");
diff --git a/core/TagState.zig b/core/TagState.zig
index f69404b2..49c7a3ed 100644
--- a/core/TagState.zig
+++ b/core/TagState.zig
@@ -252,6 +252,20 @@ pub fn wake(p: *const Pardes) ?u64 {
return soonest;
}
+/// Each view's tag state as a dump gave it, held to what it indexes: Help's
+/// hits in the tree and the registry, its rows' cursor in them, the field's
+/// caret in its text, describe-key's found leaf or struck key in its keys.
+/// One that is not (a damaged dump: the fuzz's cut and flipped bytes) is
+/// at rest, its memory of leaves kept (dump.zig afterLoad).
+pub fn loaded(p: *Pardes) void {
+ for (&p.views) |*slot| if (slot.*) |*v| {
+ const s = &v.tag_state;
+ var held = s.field.caret <= s.field.len and s.nhits <= max_hits and s.rows.at < @max(1, s.nhits) and !(s.found and s.scope_n == 0) and !(s.missed and s.scope_root == null and s.scope_n == 0);
+ for (s.hits[0..@min(s.nhits, max_hits)]) |at| held = held and at < bindings.flat.len + p.kinds.nwords;
+ if (!held) s.* = .{ .used = s.used };
+ };
+}
+
/// The last leaf run in the current level, as the line under it says it
/// (Messages' leader band): `k Hover: its summary (last used here)`, while
/// the level is shown rolled.
@@ -901,3 +915,31 @@ test "a tag out of rest keeps its rows at rest at least: a root's key cell alone
try std.testing.expectEqual(tag_rows, pane.tag_rows);
try std.testing.expectEqual(@as(u16, 0), pane.tag_top);
}
+
+test "a dump's tag state that indexes past what it names is at rest when loaded, and its frame draws" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 });
+ defer p.deinit();
+ _ = try p.setTestFile("one\n");
+ var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer frame.deinit();
+ for (" ?hel") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ const s = &p.view().tag_state;
+ try std.testing.expect(s.kind == .help and s.nhits > 0);
+ loaded(p);
+ try std.testing.expect(s.kind == .help);
+ // A hit past the tree and the registry's words, as a cut dump made one.
+ s.hits[0] = 65163;
+ s.used[0] = 'q';
+ loaded(p);
+ try std.testing.expect(s.kind == .rest and s.nhits == 0 and s.used[0] == 'q');
+ _ = try p.render(frame.allocator());
+ // A caret past the field's text, a cursor past the rows.
+ for (" ?hel") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ s.field.caret = s.field.len + 1;
+ loaded(p);
+ try std.testing.expect(s.kind == .rest);
+ for (" ?hel") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ s.rows.at = s.nhits;
+ loaded(p);
+ try std.testing.expect(s.kind == .rest);
+}
diff --git a/core/dump.zig b/core/dump.zig
index 683f043a..4bb89dae 100644
--- a/core/dump.zig
+++ b/core/dump.zig
@@ -148,6 +148,7 @@ fn afterLoad(p: *Pardes) void {
f.context.reload(p.tree_sitter_gpa, f.path, text, f.revision);
};
@import("jj.zig").loaded(p);
+ pardes.TagState.loaded(p);
}
/// A file kept slim in a dump (`dumpExit`, a closed pane's past its bound,