diff options
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 3e326bb4..b76020ca 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" }, }); @@ -2601,3 +2602,21 @@ test "a picker previews the row under its cursor from the frame its rows come, w try std.testing.expectEqualStrings(a_path, p.panes[greader].?.file.?.path); try std.testing.expectEqual(@as(?usize, 1), landingLine(p, frame.allocator(), p.panes[greader].?)); } + +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()); +} |
