Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion Strategy Triggers ^J bound widgets #814

Open
quicknir opened this issue Nov 29, 2024 · 1 comment
Open

Completion Strategy Triggers ^J bound widgets #814

quicknir opened this issue Nov 29, 2024 · 1 comment
Labels

Comments

@quicknir
Copy link

quicknir commented Nov 29, 2024

Describe the bug

If anything is bound to ^J, and the completion strategy is active for zsh-autosuggestions, then if you quickly type an auto completion, backspace, type more, backspace, etc, you'll see that whatever ^J is bound to gets called quite often.

To Reproduce

Steps to reproduce the behavior:

Have this in your .zshrc

autoload -Uz compinit
compinit
function blub() { echo hello >> ~/log.txt }
builtin zle -N blub
bindkey -v '^J' blub

. "${ZDOTDIR:h}/zsh-autosuggestions/zsh-autosuggestions.zsh"
export ZSH_AUTOSUGGEST_STRATEGY=(completion)

touch ~/log.txt. Now, if you start typing say cd Do and zsh-autosuggestions suggests "wnloads", I type wn, then backspace, then w, then backspace, etc. Just keep typing some of the suggestion and backspacing without accepting it. After doing this for a bit, you'll see that ~/log.txt has lots of lines of hello in it.

Desktop

  • Ubuntu 22.04.5 LTS (running on WSL)
  • zsh 5.9
  • I tried both 0.7.0 and 0.7.1 and saw the same behavior on both.
@quicknir quicknir added the bug label Nov 29, 2024
@quicknir
Copy link
Author

quicknir commented Nov 29, 2024

An addendum to my previous post - the way I actually noticed this is that I have a fzf command bound to ^J. So when this issue happens now, suddenly while I'm typing an empty fzf window pops up, which is obviously very disruptive. I never had this issue in the past, so I was a bit confused as to what triggered it (I quickly investigated and discarded that it was the zsh autosuggestions upgrade from 0.7.0 to 0.7.1).

It occurred to me though that maybe this was always happening in the past on zsh-autosuggestions end, but for some reasons, it didn't actually fire the fzf widget. I reset my dotfiles to an earlier state and this is exactly what I found. With my full setup from a couple weeks ago, if I define blub as above and set things up, I still see hello getting pumped into ~/log.txt, which AFAICS seems to be a bug with autosuggestions.

The change happened when I switched from the fzf-tmux script, to using fzf --tmux, with --tmux in the FZF_DEFAULT_OPTS in particular. Something about running fzf-tmux, or fzf without --tmux, seems to work such that if its called from autosuggestions it "fails gracefully" and I don't notice it occurring. But with fzf --tmux, I get the situation previously described. I can add the flag --exit-0 to my FZF_DEFAULT_OPTS, and this seems to basically bring the same behavior to fzf --tmux, albeit with a bit of a noticeable flicker.

I don't really want to have --exit-0, or to have that flicker of course. I still do think this is a bug with zsh autosuggestions; I don't think it should randomly invoke widgets bound to ^J.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant