fzf-tab-completion icon indicating copy to clipboard operation
fzf-tab-completion copied to clipboard

Cannot expand asterisk anymore

Open gbrlsnchs opened this issue 2 years ago • 2 comments

When the plugin is on, pressing tab after asterisk no longer expands to matching files. For example, typing rm * and then pressing Tab doesn't do anything (besides making highlighting being lost).

Then without the plugin it correctly expands to matching files inline.

gbrlsnchs avatar Sep 02 '22 18:09 gbrlsnchs

Which shell are you experiencing this on? bash or zsh or both?

lincheney avatar Sep 16 '22 04:09 lincheney

ZSH. I haven't tested with Bash.

gbrlsnchs avatar Sep 19 '22 18:09 gbrlsnchs

Same thing happens with bash, I've found out that this is caused by the line bind -x '"\t": fzf_bash_completion' When this is set, pressing Tab after ** doesn't expand the standard fzf fuzzy completion properly (doesn't use the custom command we could set using _fzf_compgen_dir for example).

KaXMaXimum avatar Mar 09 '23 16:03 KaXMaXimum

the bash case should be fixed by https://github.com/lincheney/fzf-tab-completion/commit/f5788de131f3d03cb3475f085e164ee10f8fc5d5

lincheney avatar Mar 15 '23 04:03 lincheney

for zsh, I'm not able to replicate doing rm *<tab> opens fzf with many results (1 result for each file + 1 result that has all files + 1 result which is a *)

lincheney avatar Mar 15 '23 05:03 lincheney

I have the same problem and could reproduce it in a vanilla shell (zsh -dfi) by executing:

source <fzf-zsh-completion.sh>
bindkey '^I' fzf_completion
autoload -Uz compinit
compinit -d /tmp/zcompdump
# fzf completion now works, asterisk expansion does not:
echo *<Tab>

f1rstlady avatar Aug 31 '23 19:08 f1rstlady

I have the same problem and could reproduce it in a vanilla shell (zsh -dfi) by executing:

Thanks 👍 I can indeed reproduce the issue using this. I'll have a look to see why this is happening

lincheney avatar Sep 01 '23 06:09 lincheney

Ok, I think what is happening is that with default zsh, tab is bound to expand-or-complete fzf-tab-completion is able to do the "complete", but it is actually the "expand" that is giving out the results which we are not doing as it is not part of the usual completion mechanism (to compare, if I also put in bindkey '^I' menu-complete, this also does not "expand" echo *) I'll need to see how to emulate this, maybe using the _expand completer

lincheney avatar Sep 04 '23 00:09 lincheney

I've made following changes https://github.com/lincheney/fzf-tab-completion/compare/1ec392c710215cfa45078d2b5b469c6119e89fb0..f0f3facf9f5ae2e1896d88e1988608e67acf49e0 which appear to make the expand work for me If anyone wants to try it out on their end too

lincheney avatar Sep 04 '23 08:09 lincheney

It works in a default shell but not with my customisations though. In my customised shell, it shows an fzf prompt with the expansion targets as source. Do you have any idea what might cause this behaviour?

f1rstlady avatar Sep 04 '23 09:09 f1rstlady

What do you mean with the expansion targets as source? Something like this? Screenshot_2023-09-04_19-21-41 Have you turned on the _expand completer? It will "expand" globs etc into completion matches for you. e.g. in my zshrc I have this line: zstyle ':completion:*' completer _expand _complete _ignored _match _correct _approximate _prefix

lincheney avatar Sep 04 '23 09:09 lincheney

I mean this (like in your screenshot but without the last two lines): 20230904-141240 I expect the tab key to not show the fzf prompt, but expand the asterisk like in default zsh.

No, I haven't enabled the _expand completer.

f1rstlady avatar Sep 04 '23 12:09 f1rstlady

ah i think i implemented it in the wrong order, it should expand then complete, but i've made it complete then expand, need to fix it

lincheney avatar Sep 05 '23 03:09 lincheney

I've pushed https://github.com/lincheney/fzf-tab-completion/commit/1d596ebea90e7fab18892ceb7af013794aad5c4d which I think this should fix it, are you able to test it out?

lincheney avatar Sep 05 '23 08:09 lincheney

Works perfectly :smiley:

f1rstlady avatar Sep 05 '23 16:09 f1rstlady

Awesome, thanks for your help on this one!

lincheney avatar Sep 06 '23 02:09 lincheney