Skip to content

Commit e037187

Browse files
committed
Fix: run _fzf-tab-apply when choices exist
1 parent 8f6531f commit e037187

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

fzf-tab.zsh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,19 @@ fzf-tab-complete() {
293293
local IN_FZF_TAB=1
294294
{
295295
zle .fzf-tab-orig-$_ftb_orig_widget || ret=$?
296-
if (( ! ret && ! _ftb_finish )); then
297-
zle _fzf-tab-apply || ret=$?
296+
# The original completion widget (expand-or-complete or its wrappers)
297+
# can return non-zero for ambiguous/list-only completions; apply choices
298+
# when present, and clear list state on successful no-choice runs.
299+
if (( ! _ftb_finish )); then
300+
if (( $#_ftb_choices )); then
301+
zle _fzf-tab-apply || ret=$?
302+
elif (( ! ret )); then
303+
# compstate is only defined when compsys runs; glob expansion bypasses it.
304+
if (( $+compstate )); then
305+
compstate[list]=
306+
compstate[insert]=
307+
fi
308+
fi
298309
fi
299310
} always {
300311
IN_FZF_TAB=0

0 commit comments

Comments
 (0)