Skip to content

Commit

Permalink
fix(completion): restore IFS even if npm completion returns error
Browse files Browse the repository at this point in the history
PR-URL: #3304
Credit: @NariyasuHeseri
Close: #3304
Reviewed-by: @wraithgar
  • Loading branch information
NariyasuHeseri authored and wraithgar committed May 26, 2021
1 parent dbbc151 commit a574b51
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/utils/completion.sh
Expand Up @@ -18,11 +18,15 @@ if type complete &>/dev/null; then
fi

local si="$IFS"
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
if ! IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
npm completion -- "${words[@]}" \
2>/dev/null)) || return $?
2>/dev/null)); then
local ret=$?
IFS="$si"
return $ret
fi
IFS="$si"
if type __ltrim_colon_completions &>/dev/null; then
__ltrim_colon_completions "${words[cword]}"
Expand All @@ -49,11 +53,16 @@ elif type compctl &>/dev/null; then
read -l line
read -ln point
si="$IFS"
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
if ! IFS=$'\n' reply=($(COMP_CWORD="$cword" \
COMP_LINE="$line" \
COMP_POINT="$point" \
npm completion -- "${words[@]}" \
2>/dev/null)) || return $?
2>/dev/null)); then

local ret=$?
IFS="$si"
return $ret
fi
IFS="$si"
}
compctl -K _npm_completion npm
Expand Down

0 comments on commit a574b51

Please sign in to comment.