Support "bind xyz" again

This was used in Vi mode (for yiw and "*p) so rejecting it is a bit reckless.
This commit is contained in:
Johannes Altmanninger 2024-04-19 22:43:48 +02:00
parent e571774c97
commit 24e4fdd695
2 changed files with 5 additions and 5 deletions

View file

@ -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.

View file

@ -241,17 +241,17 @@ pub(crate) fn parse_keys(value: &wstr) -> Result<Vec<Key>, 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());
}