mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-04 07:21:14 -03:00
Fix Vi mode delete key bindings while numlock is active
Commit8bf8b10f68(Extended & human-friendly keys, 2024-03-30) add bindings that obsolete the terminfo-based `bind -k` invocations. The `bind -k` variants were still left around[^*]. Unfortunately it forgot to add the new syntax for some special keys in Vi mode. This leads to issues if a terminal that supports the kitty keyboard protocol sends an encoding that differs from the traditional one. As far as I can tell, this happens when capslock or numlock is active. Let's add the new key names and consistently mark `bind -k` invocations as deprecated. Fixes #11303 [^*]: Support for `bind -k` will probably be removed in a future release - it leads to issues like https://github.com/fish-shell/fish-shell/issues/11278 where it's better to fail early. (cherry picked from commit733f704267)
This commit is contained in:
@@ -4,6 +4,7 @@ fish 4.0.2 (released March ??, 2025)
|
||||
This release of fish includes the following improvements compared to fish 4.0.1:
|
||||
|
||||
- Key combinations using the super (Windows/command) key can now actually be bound using the :kbd:`super-` prefix (:issue:`11217`).
|
||||
- :kbd:`delete` in Vi mode works again if numlock is active (:issue:`11303`).
|
||||
- A crash involving backspace characters was fixed (:issue:`11280`).
|
||||
- Fish 4.0.0 switched completions to be quoted instead of backslash-escaped,
|
||||
now it only does so if the completion is unambiguous to make continuing the token easier (:issue:`11271`).
|
||||
|
||||
@@ -120,7 +120,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
|
||||
bind --preset $argv alt-enter "commandline -i \n" expand-abbr
|
||||
bind --preset $argv ")" self-insert expand-abbr # Closing a command substitution.
|
||||
bind --preset $argv ctrl-space 'test -n "$(commandline)" && commandline -i " "'
|
||||
bind --preset $argv -k nul 'test -n "$(commandline)" && commandline -i " "'
|
||||
$legacy_bind --preset $argv -k nul 'test -n "$(commandline)" && commandline -i " "'
|
||||
# Shift-space behaves like space because it's easy to mistype.
|
||||
bind --preset $argv shift-space 'commandline -i " "' expand-abbr
|
||||
|
||||
|
||||
@@ -109,18 +109,24 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
|
||||
bind -s --preset -M insert ctrl-n accept-autosuggestion
|
||||
|
||||
# Vi/Vim doesn't support these keys in insert mode but that seems silly so we do so anyway.
|
||||
bind -s --preset -M insert -k home beginning-of-line
|
||||
bind -s --preset -M default -k home beginning-of-line
|
||||
bind -s --preset -M insert -k end end-of-line
|
||||
bind -s --preset -M default -k end end-of-line
|
||||
bind -s --preset -M insert home beginning-of-line
|
||||
$legacy_bind -s --preset -M insert -k home beginning-of-line
|
||||
bind -s --preset -M default home beginning-of-line
|
||||
$legacy_bind -s --preset -M default -k home beginning-of-line
|
||||
bind -s --preset -M insert end end-of-line
|
||||
$legacy_bind -s --preset -M insert -k end end-of-line
|
||||
bind -s --preset -M default end end-of-line
|
||||
$legacy_bind -s --preset -M default -k end end-of-line
|
||||
|
||||
# Vi moves the cursor back if, after deleting, it is at EOL.
|
||||
# To emulate that, move forward, then backward, which will be a NOP
|
||||
# if there is something to move forward to.
|
||||
bind -s --preset -M default x delete-char 'set fish_cursor_end_mode exclusive' forward-single-char backward-char 'set fish_cursor_end_mode inclusive'
|
||||
bind -s --preset -M default X backward-delete-char
|
||||
bind -s --preset -M insert -k dc delete-char forward-single-char backward-char
|
||||
bind -s --preset -M default -k dc delete-char 'set fish_cursor_end_mode exclusive' forward-single-char backward-char 'set fish_cursor_end_mode inclusive'
|
||||
bind -s --preset -M insert delete delete-char forward-single-char backward-char
|
||||
$legacy_bind -s --preset -M insert -k dc delete-char forward-single-char backward-char
|
||||
bind -s --preset -M default delete delete-char 'set fish_cursor_end_mode exclusive' forward-single-char backward-char 'set fish_cursor_end_mode inclusive'
|
||||
$legacy_bind -s --preset -M default -k dc delete-char 'set fish_cursor_end_mode exclusive' forward-single-char backward-char 'set fish_cursor_end_mode inclusive'
|
||||
|
||||
# Backspace deletes a char in insert mode, but not in normal/default mode.
|
||||
bind -s --preset -M insert backspace backward-delete-char
|
||||
|
||||
Reference in New Issue
Block a user