mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 16:26:08 +03:00
input: fix regression with ascii mapping to a keypad key
This commit is contained in:
@ -897,7 +897,7 @@ pub fn keyCallback(
|
|||||||
self: *Surface,
|
self: *Surface,
|
||||||
event: input.KeyEvent,
|
event: input.KeyEvent,
|
||||||
) !bool {
|
) !bool {
|
||||||
// log.debug("keyCallback event={}", .{event});
|
log.debug("keyCallback event={}", .{event});
|
||||||
|
|
||||||
// Before encoding, we see if we have any keybindings for this
|
// Before encoding, we see if we have any keybindings for this
|
||||||
// key. Those always intercept before any encoding tasks.
|
// key. Those always intercept before any encoding tasks.
|
||||||
|
@ -302,6 +302,9 @@ pub const Key = enum(c_int) {
|
|||||||
return comptime result: {
|
return comptime result: {
|
||||||
@setEvalBranchQuota(100_000);
|
@setEvalBranchQuota(100_000);
|
||||||
for (codepoint_map) |entry| {
|
for (codepoint_map) |entry| {
|
||||||
|
// No ASCII characters should ever map to a keypad key
|
||||||
|
if (entry[1].keypad()) continue;
|
||||||
|
|
||||||
if (entry[0] == @as(u21, @intCast(comptime_ch))) {
|
if (entry[0] == @as(u21, @intCast(comptime_ch))) {
|
||||||
break :result entry[1];
|
break :result entry[1];
|
||||||
}
|
}
|
||||||
@ -357,6 +360,12 @@ pub const Key = enum(c_int) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "fromASCII should not return keypad keys" {
|
||||||
|
const testing = std.testing;
|
||||||
|
try testing.expect(Key.fromASCII('0').? == .zero);
|
||||||
|
try testing.expect(Key.fromASCII('*') == null);
|
||||||
|
}
|
||||||
|
|
||||||
test "keypad keys" {
|
test "keypad keys" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
try testing.expect(Key.kp_0.keypad());
|
try testing.expect(Key.kp_0.keypad());
|
||||||
|
Reference in New Issue
Block a user