From 3734b1eb4ed431ebcf3fd945cdf17edf8f707a9b Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Tue, 29 Oct 2013 08:17:03 -0300 Subject: [PATCH] Fixed options completion --- autosuggestions.zsh | 9 +++++++-- completion-client.zsh | 4 ++-- completion-server-init.zsh | 2 +- completion-server.zsh | 5 ++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/autosuggestions.zsh b/autosuggestions.zsh index e82dfd3..074bc7d 100644 --- a/autosuggestions.zsh +++ b/autosuggestions.zsh @@ -151,14 +151,19 @@ paused-autosuggest-self-insert() { fi } -autosuggest-get-completion() { +autosuggest-get-suggested-completion() { + local words last_word local suggestion=$(autosuggest-first-completion $LBUFFER) + words=(${(z)LBUFFER}) + last_word=${words[-1]} + suggestion=${suggestion:$#last_word} RBUFFER="$suggestion" } show-suggestion() { [[ -n $ZLE_DISABLE_AUTOSUGGEST || $LBUFFER == '' ]] && return - zle .history-beginning-search-backward || autosuggest-get-completion + zle .history-beginning-search-backward ||\ + autosuggest-get-suggested-completion highlight-suggested-text } diff --git a/completion-client.zsh b/completion-client.zsh index 8edef1a..a651b6f 100755 --- a/completion-client.zsh +++ b/completion-client.zsh @@ -27,9 +27,9 @@ autosuggest-first-completion() { zsocket $ZLE_AUTOSUGGEST_SOCKET &>/dev/null || return 1 local connection=$REPLY local completion - print -u $connection $1 + print -u $connection - $1 while read -u $connection completion; do - print ${completion} + print - ${completion} done # close fd exec {connection}>&- diff --git a/completion-server-init.zsh b/completion-server-init.zsh index 33939ac..565fd45 100644 --- a/completion-server-init.zsh +++ b/completion-server-init.zsh @@ -110,7 +110,7 @@ compadd () { # description to be displayed afterwards # (( $#__dscr >= $i )) && dscr=" -- ${${__dscr[$i]}##$__hits[$i] #}" || dscr= - print $IPREFIX$apre$hpre$__hits[$i]$dsuf$hsuf$asuf$dscr + print - $IPREFIX$apre$hpre$__hits[$i]$dsuf$hsuf$asuf$dscr done diff --git a/completion-server.zsh b/completion-server.zsh index 15d0856..4b19249 100755 --- a/completion-server.zsh +++ b/completion-server.zsh @@ -19,7 +19,7 @@ zpty -w z "source '${0:a:h}/completion-server-init.zsh'" read-to-null() { while zpty -r z chunk; do [[ $chunk == *$'\0'* ]] && break - print -n $chunk + print -n - $chunk done } @@ -68,8 +68,7 @@ while zsocket -a $server &> /dev/null; do # send the longest completion back to the client, strip the last # non-printable character if (( $#current )); then - local last_word=${${(z)prefix}[-1]} - print -u $connection ${current:$#last_word:-1} + print -u $connection - ${current:0:-1} else print -u $connection '' fi