Use compadd method
This commit is contained in:
parent
486e04e3c8
commit
7724267273
|
|
@ -87,8 +87,10 @@ edit:add-var {{cmd}}~ $__zoxide_z~
|
|||
edit:add-var {{cmd}}i~ $__zoxide_zi~
|
||||
|
||||
# Load completions.
|
||||
{# zoxide-based completions are currently not possible, because Elvish only
|
||||
# prints a completion if the current token is a prefix of it. -#}
|
||||
{#-
|
||||
zoxide-based completions are currently not possible, because Elvish only prints
|
||||
a completion if the current token is a prefix of it.
|
||||
#}
|
||||
fn __zoxide_z_complete {|@rest|
|
||||
if (!= (builtin:count $rest) 2) {
|
||||
builtin:return
|
||||
|
|
|
|||
|
|
@ -38,8 +38,10 @@ function __zoxide_hook {
|
|||
}
|
||||
|
||||
# Initialize hook.
|
||||
{# Initialize $__zoxide_hooked if it does not exist. Removing this will cause
|
||||
# an unset variable error in StrictMode. #}
|
||||
{#-
|
||||
Initialize $__zoxide_hooked if it does not exist. Removing this will cause an
|
||||
unset variable error in StrictMode.
|
||||
#}
|
||||
$__zoxide_hooked = (Get-Variable __zoxide_hooked -ValueOnly -ErrorAction SilentlyContinue)
|
||||
if ($__zoxide_hooked -ne 1) {
|
||||
$__zoxide_hooked = 1
|
||||
|
|
|
|||
|
|
@ -108,12 +108,14 @@ if [[ -o zle ]]; then
|
|||
\builtin local result
|
||||
# shellcheck disable=SC2086,SC2312
|
||||
if result="$(\command zoxide query --exclude "$(__zoxide_pwd)" -i -- ${words[2,-1]})"; then
|
||||
__zoxide_result="${result}"
|
||||
result="${__zoxide_z_prefix}${result}"
|
||||
# shellcheck disable=SC2296
|
||||
compadd -Q "${(q-)result}"
|
||||
else
|
||||
__zoxide_result=''
|
||||
fi
|
||||
if [[ -v functions[.autocomplete._complete] ]]; then
|
||||
# zsh-autocomplete needs a match or it will run __zoxide_z_complete multiple times
|
||||
{#-
|
||||
zsh-autocomplete calls the completion function multiple times if no match is
|
||||
returned.
|
||||
#}
|
||||
compadd ""
|
||||
fi
|
||||
\builtin printf '\e[5n'
|
||||
|
|
@ -121,9 +123,6 @@ if [[ -o zle ]]; then
|
|||
}
|
||||
|
||||
function __zoxide_z_complete_helper() {
|
||||
\builtin local result="${__zoxide_z_prefix}${__zoxide_result}"
|
||||
# shellcheck disable=SC2296
|
||||
[[ -n "${__zoxide_result}" ]] && LBUFFER="${LBUFFER}${(q-)result}"
|
||||
\builtin zle reset-prompt
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue