Skip to content

Commit c4b6877

Browse files
committed
fix: allow non-alphabetic Ctrl keystrokes (restore Ctrl+Space support)
The previous commit restricted Ctrl keystroke validation to a-z/A-Z only, which broke built-in Emacs and Readline profiles that use Ctrl+Space (C-SPC) for set_mark / set_mark_command. Restore the original behavior of accepting any non-zero rune for Ctrl keystrokes, since terminals support combinations like C-SPC, C-@, and C-_ as valid bindings. Fixes TestValidateAllBuiltinProfiles and TestProfileSwitcher_CanSwitchTo_Valid.
1 parent 2c1a7aa commit c4b6877

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

internal/keybindings/keystroke.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,12 @@ func ValidateKeyBindings(bindings map[string]string) error {
404404
func validateKeyStroke(ks KeyStroke) error { //nolint:revive // validation covers all keystroke kinds
405405
switch ks.Kind {
406406
case KeyStrokeCtrl:
407-
// Ctrl keystrokes are limited to alphabetic runes (Ctrl+a…z / Ctrl+A…Z),
408-
// matching what the parser, exporter, and control-byte conversion support.
407+
// Ctrl keystrokes accept any non-zero rune. Both alphabetic (Ctrl+a…z) and
408+
// special characters (Ctrl+Space, Ctrl+@, Ctrl+_, etc.) are used in
409+
// built-in Emacs and Readline profiles and are valid terminal key combinations.
409410
if ks.Rune == 0 {
410411
return fmt.Errorf("ctrl keystroke rune must be non-zero")
411412
}
412-
if (ks.Rune < 'a' || ks.Rune > 'z') && (ks.Rune < 'A' || ks.Rune > 'Z') {
413-
return fmt.Errorf("ctrl keystroke rune must be a letter (a\u2013z or A\u2013Z), got %q", ks.Rune)
414-
}
415413
case KeyStrokeAlt:
416414
// Alt keys can have various runes or names, both are valid
417415
if ks.Rune == 0 && ks.Name == "" {

0 commit comments

Comments
 (0)