diff --git a/src/config/Config.zig b/src/config/Config.zig index f654b7fa8..18d34171f 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -704,6 +704,9 @@ class: ?[:0]const u8 = null, /// `ctrl+a>t`, and then bind `ctrl+a` directly, both `ctrl+a>n` and /// `ctrl+a>t` will become unbound. /// +/// * Trigger sequences are not allowed for `global:` or `all:`-prefixed +/// triggers. This is a limitation we could remove in the future. +/// /// Action is the action to take when the trigger is satisfied. It takes the /// format `action` or `action:param`. The latter form is only valid if the /// action requires a parameter. @@ -762,7 +765,10 @@ class: ?[:0]const u8 = null, /// any) will not be sent to the running program in the terminal. If /// you wish to send the encoded value to the program, specify the /// `unconsumed:` prefix before the entire keybind. For example: -/// `unconsumed:ctrl+a=reload_config` +/// `unconsumed:ctrl+a=reload_config`. `global:` and `all:`-prefixed +/// keybinds will always consume the input regardless of this setting. +/// Since they are not associated with a specific terminal surface, +/// they're never encoded. /// /// Multiple prefixes can be specified. For example, /// `global:unconsumed:ctrl+a=reload_config` will make the keybind global diff --git a/src/input/Binding.zig b/src/input/Binding.zig index b49f153b6..97798463f 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -109,7 +109,11 @@ pub const Parser = struct { const trigger = (try self.trigger_it.next()) orelse return null; // If this is our last trigger then it is our final binding. - if (!self.trigger_it.done()) return .{ .leader = trigger }; + if (!self.trigger_it.done()) { + // Global/all bindings can't be sequences + if (self.flags.global or self.flags.all) return error.InvalidFormat; + return .{ .leader = trigger }; + } // Out of triggers, yield the final action. return .{ .binding = .{ @@ -1342,6 +1346,12 @@ test "parse: global triggers" { .consumed = false, }, }, try parseSingle("unconsumed:global:a+shift=ignore")); + + // global sequences not allowed + { + var p = try Parser.init("global:a>b=ignore"); + try testing.expectError(Error.InvalidFormat, p.next()); + } } test "parse: modifier aliases" {