From 5d8a7ea7b2f41b8cb9eeed05ae3ff56209a3882b Mon Sep 17 00:00:00 2001 From: Ashley Bartlett Date: Sat, 13 Apr 2024 07:00:59 +1000 Subject: [PATCH] fix: Space-Tab interactive completions repeating (#785) --- CHANGELOG.md | 2 ++ templates/zsh.txt | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8431635..06351ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- zsh: Space-Tab completion repeating output multiple times when matching single + directory - fish: detect infinite loop when using `alias cd=z`. - fish / Nushell / PowerShell: handle queries that look like args (e.g. `z -x`). diff --git a/templates/zsh.txt b/templates/zsh.txt index b574f38..d110154 100644 --- a/templates/zsh.txt +++ b/templates/zsh.txt @@ -104,9 +104,12 @@ if [[ -o zle ]]; then # shellcheck disable=SC2086 __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. \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' fi @@ -119,6 +122,7 @@ if [[ -o zle ]]; then if [[ -n "${__zoxide_result}" ]]; then # shellcheck disable=SC2034,SC2296 BUFFER="{{ cmd }} ${(q-)__zoxide_result}" + __zoxide_result='' \builtin zle reset-prompt \builtin zle accept-line else