Allow suggestions to suggest trailing newlines

Command substitution via $() trims trailing newlines so the old approach
to reading everything from the fd was preventing suggestions from ending
with newlines.

Found the read solution here: https://stackoverflow.com/a/15184414/154703
This commit is contained in:
Eric Freese 2019-04-15 14:12:55 -06:00
parent e263845bed
commit 68343c8de4
2 changed files with 8 additions and 2 deletions

View File

@ -56,9 +56,12 @@ _zsh_autosuggest_async_request() {
_zsh_autosuggest_async_response() {
emulate -L zsh
local suggestion
if [[ -z "$2" || "$2" == "hup" ]]; then
# Read everything from the fd and give it as a suggestion
zle autosuggest-suggest -- "$(cat <&$1)"
IFS='' read -rd '' -u $1 suggestion
zle autosuggest-suggest -- "$suggestion"
# Close the fd
exec {1}<&-

View File

@ -769,9 +769,12 @@ _zsh_autosuggest_async_request() {
_zsh_autosuggest_async_response() {
emulate -L zsh
local suggestion
if [[ -z "$2" || "$2" == "hup" ]]; then
# Read everything from the fd and give it as a suggestion
zle autosuggest-suggest -- "$(cat <&$1)"
IFS='' read -rd '' -u $1 suggestion
zle autosuggest-suggest -- "$suggestion"
# Close the fd
exec {1}<&-