mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Fixed options completion
This commit is contained in:
parent
c6c97ab7bd
commit
3734b1eb4e
4 changed files with 12 additions and 8 deletions
|
@ -151,14 +151,19 @@ paused-autosuggest-self-insert() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
autosuggest-get-completion() {
|
autosuggest-get-suggested-completion() {
|
||||||
|
local words last_word
|
||||||
local suggestion=$(autosuggest-first-completion $LBUFFER)
|
local suggestion=$(autosuggest-first-completion $LBUFFER)
|
||||||
|
words=(${(z)LBUFFER})
|
||||||
|
last_word=${words[-1]}
|
||||||
|
suggestion=${suggestion:$#last_word}
|
||||||
RBUFFER="$suggestion"
|
RBUFFER="$suggestion"
|
||||||
}
|
}
|
||||||
|
|
||||||
show-suggestion() {
|
show-suggestion() {
|
||||||
[[ -n $ZLE_DISABLE_AUTOSUGGEST || $LBUFFER == '' ]] && return
|
[[ -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
|
highlight-suggested-text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,9 @@ autosuggest-first-completion() {
|
||||||
zsocket $ZLE_AUTOSUGGEST_SOCKET &>/dev/null || return 1
|
zsocket $ZLE_AUTOSUGGEST_SOCKET &>/dev/null || return 1
|
||||||
local connection=$REPLY
|
local connection=$REPLY
|
||||||
local completion
|
local completion
|
||||||
print -u $connection $1
|
print -u $connection - $1
|
||||||
while read -u $connection completion; do
|
while read -u $connection completion; do
|
||||||
print ${completion}
|
print - ${completion}
|
||||||
done
|
done
|
||||||
# close fd
|
# close fd
|
||||||
exec {connection}>&-
|
exec {connection}>&-
|
||||||
|
|
|
@ -110,7 +110,7 @@ compadd () {
|
||||||
# description to be displayed afterwards
|
# description to be displayed afterwards
|
||||||
# (( $#__dscr >= $i )) && dscr=" -- ${${__dscr[$i]}##$__hits[$i] #}" || dscr=
|
# (( $#__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
|
done
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ zpty -w z "source '${0:a:h}/completion-server-init.zsh'"
|
||||||
read-to-null() {
|
read-to-null() {
|
||||||
while zpty -r z chunk; do
|
while zpty -r z chunk; do
|
||||||
[[ $chunk == *$'\0'* ]] && break
|
[[ $chunk == *$'\0'* ]] && break
|
||||||
print -n $chunk
|
print -n - $chunk
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +68,7 @@ while zsocket -a $server &> /dev/null; do
|
||||||
# send the longest completion back to the client, strip the last
|
# send the longest completion back to the client, strip the last
|
||||||
# non-printable character
|
# non-printable character
|
||||||
if (( $#current )); then
|
if (( $#current )); then
|
||||||
local last_word=${${(z)prefix}[-1]}
|
print -u $connection - ${current:0:-1}
|
||||||
print -u $connection ${current:$#last_word:-1}
|
|
||||||
else
|
else
|
||||||
print -u $connection ''
|
print -u $connection ''
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue