Skip to content

Commit

Permalink
fix: Space-Tab interactive completions repeating (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleybartlett committed Apr 12, 2024
1 parent 36f440f commit 5d8a7ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`).

Expand Down
6 changes: 5 additions & 1 deletion templates/zsh.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 5d8a7ea

Please sign in to comment.