Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions fzf-tab.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,10 @@ disable-fzf-tab() {
unset _fzf_tab_orig_widget _fzf_tab_orig_list_groupded

# unhook compadd so that _approximate can work properply
unfunction compadd 2>/dev/null
unfunction compadd

functions[_main_complete]=$functions[_fzf_tab__main_complete]
functions[_approximate]=$functions[_fzf_tab__approximate]
functions[_approximate]=${functions[_fzf_tab__approximate]//_fzf_tab_compadd/builtin compadd}

# Don't remove .fzf-tab-orig-$_fzf_tab_orig_widget as we won't be able to reliably
# create it if enable-fzf-tab is called again.
Expand Down Expand Up @@ -572,11 +572,11 @@ enable-fzf-tab() {
functions[_fzf_tab__main_complete]=$functions[_main_complete]
function _main_complete() { _fzf_tab_complete "$@" }

# TODO: This is not a full support, see #47
# _approximate will also hook compadd
# let it call _fzf_tab_compadd instead of builtin compadd so that fzf-tab can capture result
# make sure _approximate has been loaded.
functions[_fzf_tab__approximate]=$functions[_approximate]
autoload +XUz _approximate
functions[_fzf_tab__approximate]=${functions[_approximate]//builtin compadd/_fzf_tab_compadd}
function _approximate() {
# if not called by fzf-tab, don't do anything with compadd
(( ! IN_FZF_TAB )) || unfunction compadd
Expand Down
25 changes: 25 additions & 0 deletions test/fzftab.ztst
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,31 @@
>C1:{dir1/}
>C1:{dir2/}

comptesteval 'tst_a=1; tst_b=2'
comptest $': $tst_\t'
0:variables
>line: {: $tst_a }{}
>QUERY:{tst_}
>DESCRIPTION:{parameter}
>C1:{tst_a}
>C1:{tst_b}

comptesteval 'zstyle ":completion:*" completer _complete _approximate'
comptest $': drr1\t'
0:_approximate completer(file)
>line: {: dir1/}{}

comptest $'ecoh\t'
comptesteval 'zstyle -d ":completion:*" completer'
0:_approximate completer(multiple result)
>line: {echo}{}
>QUERY:{echo}
>DESCRIPTION:{external command}
>DESCRIPTION:{builtin command}
>C2:{echo}
>C2:{echotc}
>C2:{echoti}

%clean

zmodload -ui zsh/zpty
Expand Down