diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2017-12-03 03:06:10 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-12-03 23:32:41 +0900 |
| commit | d6588fc835aff6d952d86b1bdc5ed7378a846ab9 (patch) | |
| tree | 1c40ac98d49880bd395292d8d29e7bab24ca0017 /shell | |
| parent | 5a7b41a2cf1271537c9831b0fddd38dbe58eb60d (diff) | |
| download | fzf-d6588fc835aff6d952d86b1bdc5ed7378a846ab9.tar.gz | |
[bash-completion] Fix custom completion with dynamic loader enabled
After _completion_loader is called, instead of loading the entire
completion.bash file, just restore the fzf completion for the current
command. `_fzf_orig_completion_$cmd` is only set if _completion_loader
actually changed the completion options to avoid infinite loop.
Close #1170
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/completion.bash | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/shell/completion.bash b/shell/completion.bash index 445df178..d2287c84 100644 --- a/shell/completion.bash +++ b/shell/completion.bash @@ -113,7 +113,7 @@ _fzf_opts_completion() { } _fzf_handle_dynamic_completion() { - local cmd orig_var orig ret orig_cmd + local cmd orig_var orig ret orig_cmd orig_complete cmd="$1" shift orig_cmd="$1" @@ -122,10 +122,14 @@ _fzf_handle_dynamic_completion() { if [ -n "$orig" ] && type "$orig" > /dev/null 2>&1; then $orig "$@" elif [ -n "$_fzf_completion_loader" ]; then + orig_complete=$(complete -p "$cmd") _completion_loader "$@" ret=$? - eval "$(complete | command grep "\-F.* $orig_cmd$" | _fzf_orig_completion_filter)" - source "${BASH_SOURCE[0]}" + # _completion_loader may not have updated completion for the command + if [ "$(complete -p "$cmd")" != "$orig_complete" ]; then + eval "$(complete | command grep "\-F.* $orig_cmd$" | _fzf_orig_completion_filter)" + eval "$orig_complete" + fi return $ret fi } |
