diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 14:43:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 14:54:43 -0300 |
| commit | ed518c211808ebee46f934320569d86121a8a739 (patch) | |
| tree | 685fa81689b1effe40a83feda73c0abab94271ce /core/Pick.zig | |
| parent | fca359d77acc97b4764b9daf9fc3c3724b927be2 (diff) | |
| download | pardes-ed518c211808ebee46f934320569d86121a8a739.tar.gz pardes-ed518c211808ebee46f934320569d86121a8a739.zip | |
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
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Pick.zig')
| -rw-r--r-- | core/Pick.zig | 25 |
1 files 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()); +} |
