diff --git a/share/functions/__fish_shared_key_bindings.fish b/share/functions/__fish_shared_key_bindings.fish index 668f59228..3a030ee64 100644 --- a/share/functions/__fish_shared_key_bindings.fish +++ b/share/functions/__fish_shared_key_bindings.fish @@ -161,7 +161,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod bind --preset -M paste \\ "__fish_commandline_insert_escaped \\\ \$__fish_paste_quoted" # Only insert spaces if we're either quoted or not at the beginning of the commandline # - this strips leading spaces if they would trigger histignore. - bind --preset -M paste \ 'if set -q __fish_paste_quoted[1]; or string length -q -- (commandline -c); commandline -i " "; end' + bind --preset -M paste " " self-insert-notfirst end function __fish_commandline_insert_escaped --description 'Insert the first arg escaped if a second arg is given' diff --git a/tests/bind.expect b/tests/bind.expect index bb9984dbf..3b9a3290c 100644 --- a/tests/bind.expect +++ b/tests/bind.expect @@ -299,3 +299,15 @@ expect_prompt -re {nul seen\r\nnul seen\r\nnul seen} { } unmatched { puts stderr "nul not seen" } + +# Test self-insert-notfirst. (#6603) +# Here the leading 'q's should be stripped, but the trailing ones not. +send "bind q self-insert-notfirst\r" +expect_prompt +send "qqqecho qqq" +send "\r" +expect_prompt -re {qqq} { + puts "Leading q properly stripped" +} unmatched { + puts stderr "Leading qs not stripped" +} diff --git a/tests/bind.expect.out b/tests/bind.expect.out index e8c467f53..a10e5fb0c 100644 --- a/tests/bind.expect.out +++ b/tests/bind.expect.out @@ -23,3 +23,4 @@ ctrl-o seen ctrl-w stops at : ctrl-w stops at @ nul seen +Leading q properly stripped