Browse Source

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
pull/420/head
Eric Freese 5 years ago
parent
commit
68343c8de4
2 changed files with 8 additions and 2 deletions
  1. +4
    -1
      src/async.zsh
  2. +4
    -1
      zsh-autosuggestions.zsh

+ 4
- 1
src/async.zsh 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}<&-

+ 4
- 1
zsh-autosuggestions.zsh 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}<&-

Loading…
Cancel
Save