From 24e4fdd69573e61877ba163e2c423bcc7c0e14a2 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 19 Apr 2024 22:43:48 +0200 Subject: [PATCH] Support "bind xyz" again This was used in Vi mode (for yiw and "*p) so rejecting it is a bit reckless. --- CHANGELOG.rst | 4 ++-- src/key.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4279a181f..b3f10a51f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -40,8 +40,8 @@ Notable backwards-incompatible changes Since ``,`` and ``-`` act as separators, there are some cases where they need to be written as ``comma`` and ``minus`` respectively. - To minimize gratuitous breakage, the key argument to ``bind`` is parsed using the old syntax in two cases: - - If the key argument starts with a raw escape character (``\e``) or ascii control character. Besides backwards compatibility, these "raw" bindings can be useful for keys that fish can't decode yet. - - If the key argument consists of exactly two characters, contains none of ``,`` or ``-`` and is not a named key. + - If the key argument starts with an ASCII control character (usually the escape character, ``\e``) or ASCII control character. Besides backwards compatibility, these "raw" bindings can be useful for keys that fish can't decode yet. + - If the key argument consists of two or three characters, contains none of ``,`` or ``-`` and is not a named key. - Fish no longer supports terminals that fail to ignore OSC or CSI sequences they don't recognize. The typical problem is that terminals echo the raw sequences sent by fish instead of silently ignoring them. diff --git a/src/key.rs b/src/key.rs index 50aafe91d..6ff0c02ba 100644 --- a/src/key.rs +++ b/src/key.rs @@ -241,17 +241,17 @@ pub(crate) fn parse_keys(value: &wstr) -> Result, WString> { if value.len() == 1 { // Hack: allow singular comma. res.push(canonicalize_key(Key::from_raw(first)).unwrap()); - } else if (value.len() == 2 + } else if ((2..=3).contains(&value.len()) && !value.contains('-') && !value.contains(KEY_SEPARATOR) && !KEY_NAMES.iter().any(|(_codepoint, name)| name == value) && value.as_char_slice()[0] != 'F') - || first == '\x1b' || first < ' ' { // Hack: treat as legacy syntax (meaning: not comma separated) if // 1. it doesn't contain '-' or ',' and is short enough to probably not be a key name. - // 2. it starts with raw escape (\e) or a raw ASCII control character (\c). + // 2. it starts with an ASCII control character. This can be either a multi-key binding + // or a single-key that is sent as escape sequence (starting with \e). for c in value.chars() { res.push(canonicalize_key(Key::from_raw(c)).unwrap()); }