From 5b6552d1ddfdb966318dd1c5af5ea9d5c353a8a6 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 14:10:34 -0300 Subject: TagState.loaded: a view's tag state a dump gives is held to what its own state reads, and only that, so a damaged dump in describe-key's, Help's or a level's state is at rest instead of killing the session at its first layout, frame or key, and a session's own state loads as it is (R's optional robustness item, the pre-install diff read): describe-key found has its root, not the register's, its keys a leaf of the tree or an addon's SPC word, not found and missed at once, and with no root nothing typed or the one key struck; Help's and describe-key's keys and a struck key are cells keyName names; Help's scope is what `?` was struck under (SPC's keys to a group, no more than SPC's path holds; else none); a picker's cursor is in its own rows (All's are found again at each read); the view's SPC keys (`current`'s path for every level) are cells to a group, else the view is out of SPC too; THE CAUSE: loaded() checked describe-key only for `found` with no keys, so a dump left in its state reached `s.scope_root.?` (Band.zig:119, :172; keys.zig:598), `level[at]` on an empty level (Band.zig:182, and :216 for a level unrolled on SPC keys to nothing), bindings.keyName past its table (bindings.zig:428, from TagState.zig :653 `s.scope[0]`, :725 and :768 `s.miss`, chord and keyCells) and keys.helpBack's copy of Help's scope into SPC's 4-key path; and A2's checks ran on every state's fields whatever the state: a picker's cursor was held to Help's hit count, and describe-key's `found` (left as it was under Help and at rest) to its keys, so a session where a picker's cursor had moved with Help never run, or where describe-key had found a leaf before Help or rest, loaded at rest: the loaded core's digest was not the session's, the digest a join's client checks its load against (replica.zig `r.loaded(j.digest)`), and a Restore or an Upgrade dropped the picker; each state's fields are read only under it now, and the tree a load holds keys to is every builtin's (bindings.nodeAt and the registry's words, not bindings.level, which drops the live view's frontend's others), so every process holds every view alike; RUN (TEST FIRST): TagState.zig "a dump holding describe-key's state, or Help's, or a level's, damaged where a draw or a key indexes it, loads to rest and draws and takes keys" (14 damages through byteDump and dump.load, each drawn and given Backspace, Down, Enter, Backspace): fails on the base at TagState.zig:1496 (the state not at rest), and with that check taken out 10 of the 12 cases run panic on the base: `attempt to use null value` (found, no root), `index out of bounds: index 0, len 0` (found on `SPC z z`; Help's scope `z z` and Backspace; SPC unrolled on `z z`), `integer overflow` (a struck key 0x01 with no root; Help's scope key 0x01; a struck `miss` 0x05; SPC's key 0x01), `index out of bounds: index 95, len 95` (a struck key 0x7f under `g`), `index out of bounds: index 6, len 4` (Help's scope six keys, Backspace); the two that do not panic (found on `SPC t`, a group; on `g z`, nothing) draw another child's doc; and "a tag state a session made loads as it was, its digest the session's: ..." fails on the base at TagState.zig:1525 (`expected .pick, found .rest`); both pass now; the dump fuzz seeds describe-key's state too (core/fuzz.zig: a second join dump, SPC h k `g d` found, 2048 seeds by default, the test 38 s with it); a user could have hit the panics only through a damaged dump (a join or a restore: the user's rule, a session never dies of an input), and the digest's difference on any load of a session where a view's picker cursor had moved with Help never opened, or where describe-key had found a leaf before Help or rest; core-test 1099/1270 (171 skipped: the base's 1097 + these two), shell-test 1318/1321 (3 skipped), process-test 0 of 147 failed (3 skipped), the dump fuzz at 40,000 join seeds on each of the two dumps (Help's, describe-key's) and 1,779 image seeds clean (81,785 loads, the three pinned seeds among them); load 3 to 7 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/TagState.zig | 247 +++++++++++++++++++++++++++++++++++++++++++++++++++--- core/fuzz.zig | 10 ++- 2 files changed, 246 insertions(+), 11 deletions(-) diff --git a/core/TagState.zig b/core/TagState.zig index 761eec48..5dedf62f 100644 --- a/core/TagState.zig +++ b/core/TagState.zig @@ -268,23 +268,71 @@ 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). +/// Each view's tag state as a dump gave it, held to what its state reads +/// (dump.zig afterLoad); one that is not (a damaged dump: the fuzz's cut +/// and flipped bytes) is at rest, its memory of leaves kept. Each state's +/// own fields alone: what another state left in it (describe-key's `found` +/// under Help, a picker's cursor past Help's rows) is as the session has +/// it, and so is its digest. Every state: the field's caret in its text, a +/// struck key a cell (keyName's table). Help: its hits leaves of the tree +/// or SPC words of the registry, its cursor in them, its scope what `?` was +/// struck under (SPC's keys to a group, as many as SPC's path holds: its +/// Backspace unrolls them, keys.helpBack; else none). describe-key: its +/// keys cells; found, a root's keys to a leaf, whose level Band.of +/// replays; with no root, nothing typed or the one key struck. A picker: +/// its cursor in its rows (Pick.rowAt; All's are found again at each +/// read). And the view's SPC keys, every level's path (`current`): cells +/// to a group, else the view is out of SPC too. 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); - // `:`'s hits index its own rows (the themes, the settings: Command.zig, - // which holds each where it reads it); the rest the tree's leaves. - const command = s.kind == .prompt and s.prompt.op == .command; - for (s.hits[0..@min(s.nhits, max_hits)]) |at| held = held and (command or at < bindings.flat.len + p.kinds.nwords); + const keys = s.scope[0..s.scope_n]; + var held = s.field.caret <= s.field.len and s.nhits <= max_hits and (s.miss == 0 or cells(&.{s.miss})); + switch (s.kind) { + .help => { + for (s.hits[0..@min(s.nhits, max_hits)]) |at| held = held and (at < bindings.flat.len or at - bindings.flat.len < p.kinds.nwords and p.kinds.words[at - bindings.flat.len].leader.len > 0); + held = held and s.rows.at < @max(1, s.nhits) and + if (s.scope_root == .leader) keys.len <= v.leader_keys.len and cells(keys) and reaches(p, .leader, keys, false) else keys.len == 0; + }, + .describe => held = held and cells(keys) and !(s.found and s.missed) and if (s.scope_root) |r| + r != .register and (!s.found or keys.len > 0 and reaches(p, r, keys, true)) + else + !s.found and keys.len == @intFromBool(s.missed), + .pick => if (@import("Pick.zig").byId(p, s.pick)) |pk| { + held = held and (pk.source == .all or s.rows.at < @max(1, @import("Pick.zig").count(p, pk))); + }, + .rest, .prompt, .rename => {}, + } + const spc = v.leader_keys[0..v.leader_n]; + if (v.prefix == .leader and !(cells(spc) and reaches(p, .leader, spc, false))) { + v.prefix = .none; + v.leader_n = 0; + held = false; + } if (!held) s.* = .{ .used = s.used }; }; } +/// Whether each of `keys` is a cell keyName names. +fn cells(keys: []const u8) bool { + for (keys) |k| if (k < ' ' or k > '~') return false; + return true; +} + +/// Whether `path` under `root` is a group (`leaf` false) or a leaf of the +/// tree or of the registry's SPC words. Every builtin's, whichever view's +/// frontend took it (bindings.level drops the live view's others): a load +/// holds each view the same in every process. +fn reaches(p: *const Pardes, root: Root, path: []const u8, leaf: bool) bool { + if (bindings.nodeAt(root, path)) |n| if (if (leaf) n.leaf != null else n.children.len > 0) return true; + if (root != .leader) return false; + for (p.kinds.words[0..p.kinds.nwords]) |*w| { + const keys = w.leader.slice(); + if (if (leaf) std.mem.eql(u8, keys, path) else keys.len > path.len and std.mem.startsWith(u8, keys, path)) return true; + } + return false; +} + /// Asking (SPEC §3.2, §10.2): a question waiting on the pane, its tag at /// rest, in place of the tag's own text: what it asks, `▸`, each answer's /// key and word, and how to give one (`Esc later` while SPC e has given it @@ -1364,3 +1412,182 @@ test "a click that gives the keyboard to another pane ends a level as Esc does; click(p, rt.x + config.GUTTER + 1, rt.y + pardes.BOX_H); try std.testing.expect(p.view().tag_state.kind == .rest and hostOf(p) == null); } + +test "a dump holding describe-key's state, or Help's, or a level's, damaged where a draw or a key indexes it, loads to rest and draws and takes keys" { + const Key = pardes.Key; + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 120, .rows = 40 }); + defer p.deinit(); + _ = try p.setTestFile("one\ntwo\nthree\n"); + p.clock.now_ns = 5 * std.time.ns_per_s; + p.clock.stepped_ns = p.clock.now_ns; + const typed = struct { + fn keys(q: *Pardes, cps: []const u8) void { + for (cps) |c| q.update(.{ .key = .{ .cp = c } }); + } + }.keys; + // Each case: the state a session made (describe-key's `g d` found, + // Help under `SPC t`, SPC's level rolled), then a field of it as a cut + // or flipped dump gives it. + const Case = struct { keys: []const u8, damage: *const fn (v: *View) void }; + const cases = [_]Case{ + // Found with no root (Band.takes, Band.of: `scope_root.?`). + .{ .keys = " hkgd", .damage = struct { + fn f(v: *View) void { + v.tag_state.scope_root = null; + } + }.f }, + // Found on keys no leaf of the tree is: `SPC z z` (its level + // empty, Band.of's `level[at]`), `SPC t` (a group), `g z` (none). + .{ .keys = " hkgd", .damage = struct { + fn f(v: *View) void { + v.tag_state.scope_root = .leader; + v.tag_state.scope[0..2].* = "zz".*; + v.tag_state.scope_n = 2; + } + }.f }, + .{ .keys = " hkgd", .damage = struct { + fn f(v: *View) void { + v.tag_state.scope_root = .leader; + v.tag_state.scope[0] = 't'; + } + }.f }, + .{ .keys = " hkgd", .damage = struct { + fn f(v: *View) void { + v.tag_state.scope[0] = 'z'; + } + }.f }, + // Found and missed at once; a register's root, which describe-key + // never takes. + .{ .keys = " hkgd", .damage = struct { + fn f(v: *View) void { + v.tag_state.missed = true; + } + }.f }, + .{ .keys = " hkgd", .damage = struct { + fn f(v: *View) void { + v.tag_state.scope_root = .register; + } + }.f }, + // A struck key past keyName's table, with no root (`s.scope[0]`) + // and under one (bindings.chord). + .{ .keys = " hkq", .damage = struct { + fn f(v: *View) void { + v.tag_state.scope[0] = 0x01; + } + }.f }, + .{ .keys = " hkgq", .damage = struct { + fn f(v: *View) void { + v.tag_state.scope[0] = 0x7f; + } + }.f }, + // Help's scope: more keys than SPC's path holds (Backspace copies + // them into it: keys.helpBack), keys to no group (Backspace unrolls + // their level), a key past keyName's table (its key cells). + .{ .keys = " t?", .damage = struct { + fn f(v: *View) void { + v.tag_state.scope[0..6].* = "tttttt".*; + v.tag_state.scope_n = 6; + } + }.f }, + .{ .keys = " t?", .damage = struct { + fn f(v: *View) void { + v.tag_state.scope[0..2].* = "zz".*; + v.tag_state.scope_n = 2; + } + }.f }, + .{ .keys = " t?", .damage = struct { + fn f(v: *View) void { + v.tag_state.scope[0] = 0x01; + } + }.f }, + // SPC's level rolled and shown: a struck key past keyName's table + // (`s.miss`); unrolled on SPC keys to no group (Band.of's + // `level[at]`); SPC's keys past the table (their cells, the chord). + .{ .keys = " ", .damage = struct { + fn f(v: *View) void { + v.tag_state.due_ns = 1; + v.tag_state.miss = 0x05; + } + }.f }, + .{ .keys = " ", .damage = struct { + fn f(v: *View) void { + v.leader_keys[0..2].* = "zz".*; + v.leader_n = 2; + v.tag_state.unrolled = true; + } + }.f }, + .{ .keys = " ", .damage = struct { + fn f(v: *View) void { + v.leader_keys[0] = 0x01; + v.leader_n = 1; + v.tag_state.due_ns = 1; + } + }.f }, + }; + for (cases) |case| { + p.update(.{ .key = .{ .cp = Key.escape } }); + typed(p, case.keys); + try std.testing.expect(p.view().tag_state.kind != .rest or p.view().prefix == .leader); + case.damage(p.view()); + const bytes = try pardes.dump.byteDump(p); + defer gpa.free(bytes); + // The session itself at rest again: the damage is the dump's. + p.view().tag_state = .{}; + p.view().prefix = .none; + p.view().leader_n = 0; + var notes: std.ArrayList(u8) = .empty; + defer notes.deinit(gpa); + const q = try pardes.dump.load(gpa, .{ .cols = 120, .rows = 40 }, bytes, ¬es); + defer q.deinit(); + const s = &q.view().tag_state; + try std.testing.expect(s.kind == .rest and s.root == null and !s.unrolled and s.miss == 0); + // SPC's own keys kept only where they reach a group: none here. + try std.testing.expect(q.view().prefix != .leader or q.view().leader_n == 0); + // Drawn, then keys a state reads (Enter, Backspace, Down), drawn. + q.clock.now_ns = 10 * std.time.ns_per_s; + var frame = std.heap.ArenaAllocator.init(gpa); + defer frame.deinit(); + q.sync(); + _ = try q.render(frame.allocator()); + for ([_]u21{ Key.backspace, Key.down, Key.enter, Key.backspace }) |cp| { + q.update(.{ .key = .{ .cp = cp } }); + q.sync(); + _ = try q.render(frame.allocator()); + } + } +} + +test "a tag state a session made loads as it was, its digest the session's: Help after describe-key found a leaf, a picker's cursor past Help's rows" { + const Key = pardes.Key; + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 120, .rows = 40 }); + defer p.deinit(); + _ = try p.setTestFile("one\ntwo\nthree\n"); + const same = struct { + fn digest(q: *Pardes) !void { + const bytes = try pardes.dump.byteDump(q); + defer std.testing.allocator.free(bytes); + const r = try pardes.dump.load(std.testing.allocator, .{ .cols = 120, .rows = 40 }, bytes, null); + defer r.deinit(); + try std.testing.expectEqual(q.view().tag_state.kind, r.view().tag_state.kind); + try std.testing.expectEqual(q.view().tag_state.rows.at, r.view().tag_state.rows.at); + try std.testing.expectEqual(pardes.tape.digestOf(q), pardes.tape.digestOf(r)); + } + }.digest; + // A picker of three rows, its cursor on the third (Help never opened: + // no hits), then rolled up. + pardes.Pick.open(p, 0, .list, "Refs", "", "a\nb\nc\n"); + for (0..2) |_| p.update(.{ .key = .{ .cp = Key.down } }); + try std.testing.expect(p.view().tag_state.kind == .pick and p.view().tag_state.rows.at == 2); + try same(p); + p.update(.{ .key = .{ .cp = Key.escape } }); + try same(p); + // describe-key's `g d` found, then Help over every root: `found` is + // describe-key's alone, left as it was. + for (" hkgd") |c| p.update(.{ .key = .{ .cp = c } }); + p.update(.{ .key = .{ .cp = Key.escape } }); + for (" ?") |c| p.update(.{ .key = .{ .cp = c } }); + try std.testing.expect(p.view().tag_state.kind == .help and p.view().tag_state.found); + try same(p); +} diff --git a/core/fuzz.zig b/core/fuzz.zig index 091eca63..56ded66b 100644 --- a/core/fuzz.zig +++ b/core/fuzz.zig @@ -803,6 +803,14 @@ test "a dump and an image cut, flipped and grown: refused or loaded, never a pan defer gpa.free(bytes); const image = try pardes.dump.dumpBytes(p); defer gpa.free(image); + // And one with describe-key's state (SPC h k, `g d` found: a root, its + // keys, the leaf whose level the band replays), Help's fields as Help + // left them. + p.update(.{ .key = .{ .cp = pardes.Key.escape } }); + for (" hkgd") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); + try testing.expect(p.view().tag_state.kind == .describe and p.view().tag_state.found); + const described = try pardes.dump.byteDump(p); + defer gpa.free(described); // Seconds a road, each core used (`use`). The image's past 1779 seeds // reach xitdb's own reader (a slot's tag past its kinds: a `switch` on // it), a dependency's. @@ -816,7 +824,7 @@ test "a dump and an image cut, flipped and grown: refused or loaded, never a pan // `live` (the core read in place, its own `live` undefined), a live // message's `src` length 0xAAAA when the digest walked it. try loadSeed(bytes, .join, 6356); - for ([_][]const u8{ bytes, image }, [_]Road{ .join, .restore }, [_]u64{ 2048, 1024 }) |whole, road, n| { + for ([_][]const u8{ bytes, described, image }, [_]Road{ .join, .join, .restore }, [_]u64{ 2048, 2048, 1024 }) |whole, road, n| { try loadSeed(whole, road, 0); for (1..n + 1) |seed| try loadSeed(whole, road, seed); } -- cgit v1.3 From fca359d77acc97b4764b9daf9fc3c3724b927be2 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 14:32:11 -0300 Subject: Trail, bindings: the two nits of the pre-install diff read (R): Trail.Step's doc comments said list, search and recipe steps were made "(not yet)": they are, and say where now (Pick.listed as a picker lands, Prompt.word a search prompt's, Prompt.link the sam prompts'); bindings.zig's registers test held an agent's scratch path as a register's value (`/tmp/claude-1000/wuS/r/proj/core/Query.zig`, never opened): a neutral one (`/home/user/proj/core/Query.zig`), whose last 19 cells are the same, so the test's `p …proj/core/Query.zig` is as it was; no behaviour changed; core-test 1099/1270 (171 skipped), shell-test 1318/1321 (3 skipped) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Trail.zig | 10 +++++----- core/bindings.zig | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/Trail.zig b/core/Trail.zig index ddc350ca..73ea1ffb 100644 --- a/core/Trail.zig +++ b/core/Trail.zig @@ -55,13 +55,13 @@ pub const Step = union(enum) { /// the first step. owner: u32, /// A list the pane came through (`Find pick 3/6 •2`, §5.6): its word - /// and the pickers' index for it. Made by the pickers (not yet). + /// and the pickers' index for it. Made as a picker lands (Pick.listed). list: Word, - /// A search made in the pane (`/dirty/ 3/7`, §7.3). Made by the - /// prompts (not yet). + /// A search made in the pane (`/dirty/ 3/7`, §7.3). Made by a search + /// prompt (Prompt.word). search: Word, - /// A chain of selection prompts as an Edit line (§7.5). Made by the - /// prompts (not yet). + /// A chain of selection prompts as an Edit line (§7.5). Made by the sam + /// prompts (Prompt.link). recipe: Word, }; pub const Place = struct { path: Kind.Buf(max_text) = .{}, line: u32 = 0, col: u32 = 0 }; diff --git a/core/bindings.zig b/core/bindings.zig index a8b81842..ab00c1da 100644 --- a/core/bindings.zig +++ b/core/bindings.zig @@ -582,7 +582,7 @@ test "\" shows the registers rolled, the ones holding something, each its value try p.registers.put(p.gpa, 'a', "const best = rank(q, name) orelse continue;\nreturn best;", 0, 1, true); try p.registers.put(p.gpa, '"', "self.dirty = true;", 0, 1, true); try p.registers.put(p.gpa, 'n', "ab\ncd", 0, 1, true); - try p.registers.put(p.gpa, 'p', "/tmp/claude-1000/wuS/r/proj/core/Query.zig", 0, 1, true); + try p.registers.put(p.gpa, 'p', "/home/user/proj/core/Query.zig", 0, 1, true); var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); const a = frame.allocator(); -- cgit v1.3 From ed518c211808ebee46f934320569d86121a8a739 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 14:43:11 -0300 Subject: Pick: a Messages picker's key cells are SPC h's, its level, as every other picker's are its level's (Find's `f`, Themes' `t`), so Backspace on its empty field goes back to SPC h unrolled instead of killing the session: found while item 1 held a loaded view's SPC keys to a group; THE CAUSE: Pick.words gave `.messages` the keys `hm`, its builtin's whole chord (SPC h m, a leaf), where the others name the group their builtin is in; `back` (Backspace on an empty field, no refinement to undo) puts those keys in the view's SPC path and unrolls their level, so the level of a leaf, which has no children: Band.takes still gives a band of doc_rows and Band.of indexes `level[at]` (Band.zig:216) on the empty level; RUN (TEST FIRST): Pick.zig "Backspace on a Messages picker's empty field goes back to the level it was run from, SPC h, unrolled and drawn: ..." fails on the base at its SPC path (`hm` for `h`), and a probe on the base that draws after the Backspace panics: `index out of bounds: index 0, len 0` at Band.zig:216 (Band.of, from draw.zig joinBand, renderPane, render); passes now; THE FIX: `.messages`' keys `h` (its head `␣ h Messages`, as Find's is `␣ f Find`); Actions keep `la` (a code actions picker's Backspace edits its field: it never goes back), as Themes' Backspace does; a user could hit it with three keys and a Backspace: SPC h m, then Backspace; core-test 1100/1271 (171 skipped; one failure in the whole run, dev/host_io.zig "the walk reaches the leaf: bash -c 'sleep 30' takes the tty" (its pid walk found no child, expected 1, at load 6 to 8), passes run alone: a process-tree probe's timing, nothing of this change), shell-test 1319/1322 (3 skipped), process-test 0 of 147 failed (3 skipped); load 5 to 8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Pick.zig | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/core/Pick.zig b/core/Pick.zig index 10c80dfc..618d62a2 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -57,8 +57,9 @@ const Key = pardes.Key; /// (SPC l a, the body showing the one under the cursor as its edit). pub const Source = enum { find, grep, recent, panes, symbols, all, jumplist, list, messages, themes, actions }; -/// Each source's word in the tag and the leader keys of the builtin that -/// opens it, its key cells (`␣ f Find`). +/// Each source's word in the tag and its key cells (`␣ f Find`); a +/// source whose Backspace leaves it (`back`) goes back to the SPC level of +/// those keys: a group's. const words = std.EnumArray(Source, struct { word: []const u8, keys: []const u8 }).init(.{ .find = .{ .word = "Find", .keys = "f" }, .grep = .{ .word = "Grep", .keys = "f" }, @@ -68,7 +69,7 @@ const words = std.EnumArray(Source, struct { word: []const u8, keys: []const u8 .all = .{ .word = "All", .keys = "" }, .jumplist = .{ .word = "Jumplist", .keys = "j" }, .list = .{ .word = "List", .keys = "l" }, - .messages = .{ .word = "Messages", .keys = "hm" }, + .messages = .{ .word = "Messages", .keys = "h" }, .themes = .{ .word = "Themes", .keys = "t" }, .actions = .{ .word = "Actions", .keys = "la" }, }); @@ -2554,3 +2555,21 @@ test "code actions: a row that cannot be applied (a command's, an edit reaching }; try std.testing.expectEqual(@as(?u16, @intCast((pane.rows + 2) / 3)), row_at); } + +test "Backspace on a Messages picker's empty field goes back to the level it was run from, SPC h, unrolled and drawn: its keys are its level's, as every other picker's are" { + const Key_ = pardes.Key; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 }); + defer p.deinit(); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + _ = try p.setTestFile("one\ntwo\n"); + for (" hm") |c| p.update(.{ .key = .{ .cp = c } }); + try std.testing.expectEqual(Source.messages, live(p).?.source); + p.sync(); + _ = try p.render(frame.allocator()); + p.update(.{ .key = .{ .cp = Key_.backspace } }); + try std.testing.expect(p.view().prefix == .leader and p.view().tag_state.unrolled); + try std.testing.expectEqualStrings("h", p.view().leader_keys[0..p.view().leader_n]); + p.sync(); + _ = try p.render(frame.allocator()); +} -- cgit v1.3