fix: Space-Tab interactive completions repeating (#785)

This commit is contained in:
Ashley Bartlett 2024-04-13 07:00:59 +10:00 committed by GitHub
parent 36f440f3e3
commit 5d8a7ea7b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- zsh: Space-Tab completion repeating output multiple times when matching single
directory
- fish: detect infinite loop when using `alias cd=z`. - fish: detect infinite loop when using `alias cd=z`.
- fish / Nushell / PowerShell: handle queries that look like args (e.g. `z -x`). - fish / Nushell / PowerShell: handle queries that look like args (e.g. `z -x`).

View File

@ -104,9 +104,12 @@ if [[ -o zle ]]; then
# shellcheck disable=SC2086 # shellcheck disable=SC2086
__zoxide_result="$(\command zoxide query --exclude "$(__zoxide_pwd || \builtin true)" --interactive -- ${words[2,-1]})" || __zoxide_result='' __zoxide_result="$(\command zoxide query --exclude "$(__zoxide_pwd || \builtin true)" --interactive -- ${words[2,-1]})" || __zoxide_result=''
# Set a result to ensure completion doesn't re-run
compadd -Q ""
# Bind '\e[0n' to helper function. # Bind '\e[0n' to helper function.
\builtin bindkey '\e[0n' '__zoxide_z_complete_helper' \builtin bindkey '\e[0n' '__zoxide_z_complete_helper'
# Send '\e[0n' to console input. # Sends query device status code, which results in a '\e[0n' being sent to console input.
\builtin printf '\e[5n' \builtin printf '\e[5n'
fi fi
@ -119,6 +122,7 @@ if [[ -o zle ]]; then
if [[ -n "${__zoxide_result}" ]]; then if [[ -n "${__zoxide_result}" ]]; then
# shellcheck disable=SC2034,SC2296 # shellcheck disable=SC2034,SC2296
BUFFER="{{ cmd }} ${(q-)__zoxide_result}" BUFFER="{{ cmd }} ${(q-)__zoxide_result}"
__zoxide_result=''
\builtin zle reset-prompt \builtin zle reset-prompt
\builtin zle accept-line \builtin zle accept-line
else else