a9b271c8
fix: dismiss native command hints on invalid keys
a73x 2026-09-07 14:37
Commit message
src/gui/interaction.zig
| Old | New | ||
|---|---|---|---|
| @@ -240,7 +240,7 @@ pub const Controller = struct { | |||
| 240 | try self.finishOpening(); | 240 | try self.finishOpening(); |
| 241 | ws.cancel(); | 241 | ws.cancel(); |
| 242 | }, | 242 | }, |
| 243 | else => self.notice = "v new below, b new beside, hjkl focus, r resize, d detach, x end, p actions, Enter picks session", | 243 | else => {}, |
| 244 | } | 244 | } |
| 245 | self.dirty = true; | 245 | self.dirty = true; |
| 246 | } | 246 | } |
| @@ -873,6 +873,18 @@ test "controller preserves exact held keys across modal dismissal and text edges | |||
| 873 | ui.keyUp(102); | 873 | ui.keyUp(102); |
| 874 | try ui.keyDown(.{ .code = 102, .prefix = true }); | 874 | try ui.keyDown(.{ .code = 102, .prefix = true }); |
| 875 | try std.testing.expect(ui.command_mode); | 875 | try std.testing.expect(ui.command_mode); |
| 876 | ui.keyUp(102); | ||
| 877 | // Unbound commands dismiss the hint but retain ownership until release. | ||
| 878 | ui.dirty = false; | ||
| 879 | try ui.keyDown(.{ .code = 115 }); | ||
| 880 | try std.testing.expect(!ui.command_mode and ui.dirty and ui.suppress_text); | ||
| 881 | try std.testing.expectEqualStrings("", ui.notice); | ||
| 882 | try std.testing.expectEqual(@as(?u32, 115), ui.consumed_key); | ||
| 883 | try ui.keyDown(.{ .code = 115, .repeat = true }); | ||
| 884 | try std.testing.expect(!ui.command_mode and ui.suppress_text); | ||
| 885 | ui.keyUp(115); | ||
| 886 | try std.testing.expect(ui.consumed_key == null and !ui.suppress_text); | ||
| 887 | try ui.keyDown(.{ .code = 102, .prefix = true }); | ||
| 876 | try ui.keyDown(.{ .code = 114, .kind = .r }); | 888 | try ui.keyDown(.{ .code = 114, .kind = .r }); |
| 877 | try std.testing.expect(ui.resize_mode and !ui.command_mode); | 889 | try std.testing.expect(ui.resize_mode and !ui.command_mode); |
| 878 | ui.focusLost(); | 890 | ui.focusLost(); |