From 891fa79e0676ce475592b0e666a2e21e07665560 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 3 May 2025 19:17:53 +0900 Subject: [PATCH] Remove ineffective attempt of redraw-current-line in Bash integration The current version attempts to run "redraw-current-line" and "__zoxide_z_complete_helper" by 1) first replacing the keybinding to \[0n to "redraw-current-line", 2) printing \e[5n, 3) replacing the keybinding to \e[0n with "__zoxide_z_complete_helper", and 4) finally printing \e[5n. However, this does not work as expected. This ends up running "__zoxide_z_complete_helper" twice. This is because Bash/Readline processes the next inputs after the current completion finishes. Since the above steps 1-4 are performed inside the completion function, Bash/Readline starts processing the response \e[0n (even if it is immediately returned with zero time) only after the keybinding to \e[0n is replaced with "__zoxide_z_complete_helper". In the first place, Bash/Readline automatically redraws the command line after processing the keybinding with "bind -x", so one does not need to explicitly call "redraw-current-line". This patch simply removes steps 1-2, which did not perform what was expected. --- templates/bash.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/templates/bash.txt b/templates/bash.txt index 162ca6c..61b041f 100644 --- a/templates/bash.txt +++ b/templates/bash.txt @@ -157,9 +157,6 @@ if [[ ${BASH_VERSINFO[0]:-0} -eq 4 && ${BASH_VERSINFO[1]:-0} -ge 4 || ${BASH_VER elif [[ -z ${COMP_WORDS[-1]} ]]; then # shellcheck disable=SC2312 __zoxide_result="$(\command zoxide query --exclude "$(__zoxide_pwd)" --interactive -- "{{ "${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-2}" }}")" && { - \builtin bind '"\e[0n": redraw-current-line' - \builtin printf '\e[5n' - # shellcheck disable=SC2016 \builtin bind -x '"\e[0n": __zoxide_z_complete_helper "${result}"' \builtin printf '\e[5n'