mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
input: parse binds containing equal signs correctly (#7544)
Since the W3C rewrite we're able to specify codepoints like `+` directly in the config format who otherwise have special meanings. Turns out we forgot to do the same for `=`.
This commit is contained in:
@ -63,9 +63,11 @@ pub const Parser = struct {
|
||||
const flags, const start_idx = try parseFlags(raw_input);
|
||||
const input = raw_input[start_idx..];
|
||||
|
||||
// Find the first = which splits are mapping into the trigger
|
||||
// Find the last = which splits are mapping into the trigger
|
||||
// and action, respectively.
|
||||
const eql_idx = std.mem.indexOf(u8, input, "=") orelse return Error.InvalidFormat;
|
||||
// We use the last = because the keybind itself could contain
|
||||
// raw equal signs (for the = codepoint)
|
||||
const eql_idx = std.mem.lastIndexOf(u8, input, "=") orelse return Error.InvalidFormat;
|
||||
|
||||
// Sequence iterator goes up to the equal, action is after. We can
|
||||
// parse the action now.
|
||||
@ -2191,6 +2193,32 @@ test "parse: plus sign" {
|
||||
try testing.expectError(Error.InvalidFormat, parseSingle("++=ignore"));
|
||||
}
|
||||
|
||||
test "parse: equals sign" {
|
||||
const testing = std.testing;
|
||||
|
||||
try testing.expectEqual(
|
||||
Binding{
|
||||
.trigger = .{ .key = .{ .unicode = '=' } },
|
||||
.action = .ignore,
|
||||
},
|
||||
try parseSingle("==ignore"),
|
||||
);
|
||||
|
||||
// Modifier
|
||||
try testing.expectEqual(
|
||||
Binding{
|
||||
.trigger = .{
|
||||
.key = .{ .unicode = '=' },
|
||||
.mods = .{ .ctrl = true },
|
||||
},
|
||||
.action = .ignore,
|
||||
},
|
||||
try parseSingle("ctrl+==ignore"),
|
||||
);
|
||||
|
||||
try testing.expectError(Error.InvalidFormat, parseSingle("=ignore"));
|
||||
}
|
||||
|
||||
// For Ghostty 1.2+ we changed our key names to match the W3C and removed
|
||||
// `physical:`. This tests the backwards compatibility with the old format.
|
||||
// Note that our backwards compatibility isn't 100% perfect since triggers
|
||||
|
Reference in New Issue
Block a user