Work around to prevent premature Ctrl-D from inserting spaces

Pressing Ctrl-D while a command is running results in a null key code in
our input queue. That key code is bound to insert a space (without expanding
abbreviations). Make it only insert a space if the commandline is non-empty,
to accommodate this use case.

This probably affects other keys as well.

Closes #8871
This commit is contained in:
Johannes Altmanninger 2022-05-11 21:57:37 +02:00
parent 32aef855b7
commit a8b3922a74
2 changed files with 2 additions and 1 deletions

View file

@ -83,6 +83,7 @@ Interactive improvements
- The ``vared`` command can now successfully edit variables named "tmp" or "prompt" (:issue:`8836`).
- ``time`` now emits an error if used after the first command in a pipeline (:issue:`8841`).
- ``fish_add_path`` now prints a message for skipped non-existent paths when using the ``-v`` flag.
- Since fish 3.2.0, pressing :kbd:`Control-D` while a command is running would end up inserting a space into the next commandline, which has been fixed (:issue:`8871`).
New or improved bindings
^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -186,7 +186,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
# Closing a command substitution expands abbreviations
bind --preset $argv ")" self-insert expand-abbr
# Ctrl-space inserts space without expanding abbrs
bind --preset $argv -k nul 'commandline -i " "'
bind --preset $argv -k nul 'test -n "$(commandline)" && commandline -i " "'
# Shift-space (CSI u escape sequence) behaves like space because it's easy to mistype.
bind --preset $argv \e\[32\;2u 'commandline -i " "; commandline -f expand-abbr'.