diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3acdefa18..3640c6ec6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1141,7 +1141,7 @@ New or improved bindings - The binding for :kbd:`",*,y` now uses ``fish_clipboard_copy``, allowing it to support more than just ``xsel``. - The :kbd:`ctrl-space` binding can be correctly customised (:issue:`7922`). - ``exit`` works correctly in bindings (:issue:`7967`). -- The :kbd:`F1` binding, which opens the manual page for the current command, now works around a bug in certain ``less`` versions that fail to clear the screen (:issue:`7863`). +- The :kbd:`f1` binding, which opens the manual page for the current command, now works around a bug in certain ``less`` versions that fail to clear the screen (:issue:`7863`). - The binding for :kbd:`alt-s` now toggles whether ``sudo`` is prepended, even when it took the commandline from history instead of only adding it. - The new functions ``fish_commandline_prepend`` and ``fish_commandline_append`` allow toggling the presence of a prefix/suffix on the current commandline. (:issue:`7905`). - ``backward-kill-path-component`` :kbd:`ctrl-w`) no longer erases parts of two tokens when the cursor is positioned immediately after ``/``. (:issue:`6258`). @@ -3547,7 +3547,7 @@ Other notable fixes and improvements - ``type`` has a new ``-q`` option to suppress output (:issue:`1540` and, like other shells, ``type -a`` now prints all matches for a command (:issue:`261`). -- Pressing F1 now shows the manual page for the current command +- Pressing :kbd:`f1` now shows the manual page for the current command (:issue:`1063`). - ``fish_title`` functions have access to the arguments of the currently running argument as ``$argv[1]`` (:issue:`1542`). diff --git a/doc_src/cmds/bind.rst b/doc_src/cmds/bind.rst index 0d8586908..d98d2daea 100644 --- a/doc_src/cmds/bind.rst +++ b/doc_src/cmds/bind.rst @@ -38,7 +38,7 @@ They are: - ``end``, - ``enter``, - ``escape``, -- ``F1`` through ``F12``. +- ``f1`` through ``f12``. - ``home``, - ``insert``, - ``minus`` (``-``), diff --git a/doc_src/interactive.rst b/doc_src/interactive.rst index 45aa39661..38d557195 100644 --- a/doc_src/interactive.rst +++ b/doc_src/interactive.rst @@ -327,7 +327,7 @@ Some bindings are common across Emacs and vi mode, because they aren't text edit - :kbd:`alt-d` moves the next word to the :ref:`killring`. -- :kbd:`alt-h` (or :kbd:`F1`) shows the manual page for the current command, if one exists. +- :kbd:`alt-h` (or :kbd:`f1`) shows the manual page for the current command, if one exists. - :kbd:`alt-l` lists the contents of the current directory, unless the cursor is over a directory argument, in which case the contents of that directory will be listed. diff --git a/share/completions/bind.fish b/share/completions/bind.fish index 1eead74e1..bf1388026 100644 --- a/share/completions/bind.fish +++ b/share/completions/bind.fish @@ -70,7 +70,7 @@ function __fish_bind_complete printf '%sshift-\tShift modifier…\n' $prefix set -l key_names minus comma backspace delete escape \ enter up down left right pageup pagedown home end insert tab \ - space F(seq 12) + space f(seq 12) printf '%s\tNamed key\n' $prefix$key_names end end diff --git a/share/functions/__fish_shared_key_bindings.fish b/share/functions/__fish_shared_key_bindings.fish index 3d0061945..a8b7dc797 100644 --- a/share/functions/__fish_shared_key_bindings.fish +++ b/share/functions/__fish_shared_key_bindings.fish @@ -82,8 +82,8 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod bind --preset $argv alt-s 'for cmd in sudo doas please; if command -q $cmd; fish_commandline_prepend $cmd; break; end; end' - # Allow reading manpages by pressing F1 (many GUI applications) or Alt+h (like in zsh). - bind --preset $argv F1 __fish_man_page + # Allow reading manpages by pressing f1 (many GUI applications) or Alt+h (like in zsh). + bind --preset $argv f1 __fish_man_page $legacy_bind --preset $argv -k f1 __fish_man_page bind --preset $argv alt-h __fish_man_page diff --git a/src/key.rs b/src/key.rs index 380d92d85..d00036816 100644 --- a/src/key.rs +++ b/src/key.rs @@ -245,7 +245,8 @@ pub(crate) fn parse_keys(value: &wstr) -> Result, WString> { && !value.contains('-') && !value.contains(KEY_SEPARATOR) && !KEY_NAMES.iter().any(|(_codepoint, name)| name == value) - && value.as_char_slice()[0] != 'F') + && value.as_char_slice()[0] != 'F' + && !(value.as_char_slice()[0] == 'f' && value.char_at(1).is_ascii_digit())) || first < ' ' { // Hack: treat as legacy syntax (meaning: not comma separated) if @@ -290,13 +291,13 @@ pub(crate) fn parse_keys(value: &wstr) -> Result, WString> { modifiers, codepoint, })? - } else if codepoint.is_none() && key_name.starts_with('F') && key_name.len() <= 3 { - let num = key_name.strip_prefix('F').unwrap(); + } else if codepoint.is_none() && key_name.starts_with('f') && key_name.len() <= 3 { + let num = key_name.strip_prefix('f').unwrap(); let codepoint = match fish_wcstoi(num) { 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 'F%s'", + "only f1 through f12 are supported, not 'f%s'", num, )); } @@ -391,7 +392,7 @@ impl From for WString { .contains(&key.codepoint) .then(|| { sprintf!( - "F%d", + "f%d", u32::from(key.codepoint) - u32::from(function_key(1)) + 1 ) }) diff --git a/src/tests/key.rs b/src/tests/key.rs index c25b8225b..4b8350759 100644 --- a/src/tests/key.rs +++ b/src/tests/key.rs @@ -11,9 +11,10 @@ fn test_parse_key() { assert_eq!(parse_keys(L!("ctrl-a")), Ok(vec![ctrl('a')])); assert_eq!(parse_keys(L!("c-a")), Ok(vec![ctrl('a')])); assert_eq!(parse_keys(L!("\x01")), Ok(vec![ctrl('a')])); - assert!(parse_keys(L!("F0")).is_err()); + assert!(parse_keys(L!("f0")).is_err()); assert_eq!( - parse_keys(L!("F1")), + parse_keys(L!("f1")), Ok(vec![Key::from_raw(function_key(1))]) ); + assert!(parse_keys(L!("F1")).is_err()); }