mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-01 22:57:14 +08:00
Fix parsing of single-digit function keys
This commit is contained in:
parent
7fd018e851
commit
d025b245f6
|
@ -233,6 +233,7 @@ pub(crate) fn parse_keys(value: &wstr) -> Result<Vec<Key>, WString> {
|
|||
&& !value.contains('-')
|
||||
&& !value.contains(KEY_SEPARATOR)
|
||||
&& !KEY_NAMES.iter().any(|(_codepoint, name)| name == value))
|
||||
&& value.as_char_slice()[0] != 'F'
|
||||
|| (first == '\x1b' || first == ascii_control(first))
|
||||
{
|
||||
// Hack: treat as legacy syntax (meaning: not comma separated) if
|
||||
|
@ -282,9 +283,8 @@ pub(crate) fn parse_keys(value: &wstr) -> Result<Vec<Key>, WString> {
|
|||
Ok(n) if (1..=12).contains(&n) => function_key(u32::try_from(n).unwrap()),
|
||||
_ => {
|
||||
return Err(wgettext_fmt!(
|
||||
"only F1 through F12 are supported, not '%s'",
|
||||
"only F1 through F12 are supported, not 'F%s'",
|
||||
num,
|
||||
full_key_name
|
||||
));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::key::{self, ctrl, parse_keys, Key};
|
||||
use crate::key::{self, ctrl, function_key, parse_keys, Key};
|
||||
use crate::wchar::prelude::*;
|
||||
|
||||
#[test]
|
||||
|
@ -10,4 +10,9 @@ fn test_parse_key() {
|
|||
assert_eq!(parse_keys(L!("\x1b")), Ok(vec![Key::from_raw(key::Escape)]));
|
||||
assert_eq!(parse_keys(L!("ctrl-a")), Ok(vec![ctrl('a')]));
|
||||
assert_eq!(parse_keys(L!("\x01")), Ok(vec![ctrl('a')]));
|
||||
assert!(parse_keys(L!("F0")).is_err());
|
||||
assert_eq!(
|
||||
parse_keys(L!("F1")),
|
||||
Ok(vec![Key::from_raw(function_key(1))])
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user