diff --git a/templates/elvish.txt b/templates/elvish.txt index a236c8b..ea1a5b1 100644 --- a/templates/elvish.txt +++ b/templates/elvish.txt @@ -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 diff --git a/templates/powershell.txt b/templates/powershell.txt index 6c89fc1..6edc3cb 100644 --- a/templates/powershell.txt +++ b/templates/powershell.txt @@ -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 diff --git a/templates/zsh.txt b/templates/zsh.txt index b6ad309..2db8a2a 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -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 }