lincheney / fzf-tab-completion

Tab completion using fzf
GNU General Public License v3.0
623 stars 40 forks source link

`adb` completion hangs on cancel #76

Closed przepompownia closed 1 year ago

przepompownia commented 1 year ago

Steps:

For me, it hangs image so I have to (carefully) run adb kill-server from other console, to free the input.

I can reproduce it with no android phone connected.

lincheney commented 1 year ago

Hello

I've tried to reproduce this behaviour and it hangs on zsh including if I select an entry, but it does not hang on bash. Can you confirm this is the same for you?

przepompownia commented 1 year ago

Hi @lincheney

I can reproduce it with ~/.bashrc-fzf-tab.sh as below

. /usr/share/bash-completion/bash_completion
. "$(realpath "$(dirname ${BASH_SOURCE[0]})")/.src/external/fzf-tab-completion/bash/fzf-bash-completion.sh"
bind -x '"\t": fzf_bash_completion'
bind '"\es": menu-complete'
bind '"\eS": menu-complete-backward'

(edit: copy-paste from my .inputrc without testing).

and env -i -- bash --rcfile ~/.bashrc-fzf-tab.sh. More: it hangs also at confirming (then I get adb: pull requires an argument so it looks like if completion was work but problem with displaying). I use tmux within kitty.

After skipping tmux, I cannot reproduce it on kitty (on xterm too).

Can you reproduce it inside tmux?

lincheney commented 1 year ago

Hello

I have tried doing tab completion with bash inside tmux and the completion is working instantaneously for me (or close enough). If you do set -x and then do the tab completion, this might show you where it is hanging in the code. Also, if this is tmux related, are you able to tell if you have configured any tmux settings that may be related?

przepompownia commented 1 year ago

I need some free time to bisect my bash/kitty/tmux environment.

Currently in my regular environment set -x revealed that I use https://sw.kovidgoyal.net/kitty/shell-integration/#manual-shell-integration (in Debian it comes from kitty-shell-integration) but it seems to not affect this behavior.

At the moment I can put some tail from verbose stderr:

[[1m+[[0m _fzf_bash_completion_quote_filenames adb pu adb
[[1m+[[0m '[' '' '!=' 1 -a '' = 1 ']'
[[1m+[[0m cat
[[1m+[[0m '[' '' = 1 ']'
[[1m+[[0m ((  0 == 124  )) <---- before press Esc
[[1m+[[0m value=
[[1m+[[0m code=130
[[1m+[[0m tr '\n' ' '
[[1m+[[0m value=' '
[[1m+[[0m value=
[[1m+[[0m printf 'COMPREPLY=%q\n' ''
[[1m+[[0m printf 'code=%q\n' 130
[[1m+[[0m descend_process 347585
[[1m+[[0m printf '%s\n' 347585
[[1m+[[0m pgrep -P 347585
[[1m+[[0m kill -- 347585
przepompownia commented 1 year ago

@lincheney please run adb kill-server each time before trying to reproduce it.

przepompownia commented 1 year ago

It turns out that my bash settings do not matter but

set-option -g update-environment ''

in ~/.tmux.conf does. I have no idea why this is related to cancellation.

lincheney commented 1 year ago

I tried with that tmux setting, but unfortunately I am still not able to get it to freeze. This is the tmux conf I tried

set -s escape-time 0
set-option -g update-environment ''

Looking at the logs you have provided, I assume the kill -- 347585 is the last thing it does before it hangs? I wonder if it is actually the same issue that I experienced with adb in zsh, where a forked process still has the stdout handle open, so the subshell reading from it hangs. I have ported the same fix to bash, are you able to see if it solves your issue? https://github.com/lincheney/fzf-tab-completion/commit/8185f5c9495699fbd89e49f8dba8ca4ff55912cc

przepompownia commented 1 year ago

It seems to fix the bug for me! Thank you again, especially that the next time it required non-trivial approach.