From a8b3922a7449e7048037a90fc4e864724e4fa8a1 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 11 May 2022 21:57:37 +0200 Subject: [PATCH] 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 --- CHANGELOG.rst | 1 + share/functions/__fish_shared_key_bindings.fish | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a6cc07393..5fc3315f0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/share/functions/__fish_shared_key_bindings.fish b/share/functions/__fish_shared_key_bindings.fish index bec3da179..e3bcbe174 100644 --- a/share/functions/__fish_shared_key_bindings.fish +++ b/share/functions/__fish_shared_key_bindings.fish @@ -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'.