diff --git a/CHANGELOG.md b/CHANGELOG.md index 77e5932..e9fe820 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- zsh: completions clashing with `zsh-autocomplete`. + ## [0.8.3] - 2022-09-02 ### Added 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 3abb781..c850847 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -108,23 +108,21 @@ 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='' +{#- + zsh-autocomplete calls the completion function multiple times if no match is + returned. +#} + compadd "" fi \builtin printf '\e[5n' fi } - 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 - } - - \builtin zle -N __zoxide_z_complete_helper - \builtin bindkey "\e[0n" __zoxide_z_complete_helper + \builtin bindkey "\e[0n" 'reset-prompt' if [[ "${+functions[compdef]}" -ne 0 ]]; then \compdef -d {{cmd}} \compdef -d {{cmd}}i