diff options
| -rw-r--r-- | docs/typ/cheatsheet.typ | 1 | ||||
| -rw-r--r-- | src/config.zig | 19 | ||||
| -rw-r--r-- | test/snapshots/leader.snap | 2 |
3 files changed, 19 insertions, 3 deletions
diff --git a/docs/typ/cheatsheet.typ b/docs/typ/cheatsheet.typ index 0487611a..878db27e 100644 --- a/docs/typ/cheatsheet.typ +++ b/docs/typ/cheatsheet.typ @@ -112,6 +112,7 @@ Helix-style: motions *select*, then an edit acts on the selection. Mode box: bla key("SPC s D"), word("Detach"), key("SPC h t"), word("Tutor"), key("SPC h m"), word("Messages"), + key("SPC q"), word("Exit"), ) == Terminals and commands diff --git a/src/config.zig b/src/config.zig index 86baa9fe..e9595a2a 100644 --- a/src/config.zig +++ b/src/config.zig @@ -57,7 +57,7 @@ pub const leader_path = paths: { .Redo = null, .Repl = null, .Kill = null, - .Exit = null, + .Exit = "q", .ClipYank = "y", .ClipYankMain = "Y", .ClipPaste = "p", @@ -193,7 +193,7 @@ pub const leader_path = paths: { test "Space-k is unbound while Exit, Kill and other k chords remain available" { try std.testing.expect(leader_path.get(.Kill) == null); - try std.testing.expect(leader_path.get(.Exit) == null); + try std.testing.expectEqualStrings("q", leader_path.get(.Exit).?); try std.testing.expectEqualStrings("wk", leader_path.get(.Up).?); try std.testing.expectEqualStrings("lk", leader_path.get(.Hover).?); try std.testing.expectEqualStrings("d", leader_path.get(.Del).?); @@ -222,6 +222,21 @@ test "Space-k is unbound while Exit, Kill and other k chords remain available" { try std.testing.expect(p.quit); } +test "SPC q runs Exit: refused once over unsaved text, as the tag word is, then it quits" { + const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer p.deinit(); + const pane = try p.setTestFile("text\n"); + pane.file.?.saved_revision = pane.file.?.revision -% 1; // modified + pane.file.?.saved_hash = 0; // edited: what it had is not what it has + while (p.nextEffect()) |_| {} + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = 'q' } }); + try std.testing.expect(!p.quit); + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = 'q' } }); + try std.testing.expect(p.quit); +} + pub const look_key: []const Chord = &.{.{ .cp = Key.enter }}; pub const exec_key: []const Chord = &.{.{ .cp = Key.tab }}; pub const look_button: Mouse.Button = .right; diff --git a/test/snapshots/leader.snap b/test/snapshots/leader.snap index d8bbf233..02205190 100644 --- a/test/snapshots/leader.snap +++ b/test/snapshots/leader.snap @@ -14,7 +14,7 @@ key esc settle 100 stable 400 5000 snap abandoned -key space q +key space x stable 400 5000 snap unmapped |
