Skip to content

Commit

Permalink
syntax: fix a bug that argument completion is attempted in nested com…
Browse files Browse the repository at this point in the history
…mands
  • Loading branch information
akinomyoga committed Sep 23, 2021
1 parent 4117d1b commit 6987ae8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/core-complete.sh
Expand Up @@ -1405,7 +1405,9 @@ function ble/complete/source:argument/.progcomp {
else
ble/util/assign compdef 'complete -p -- "$compcmd" 2>/dev/null'
fi
compdef=${compdef%"$compcmd"} # strip -I, -D, or command_name
# strip -I, -D, or command_name
# #D1579 bash-5.1 では空コマンドに限り '' と出力する様である。
compdef=${compdef%"${compcmd:-''}"}
compdef=${compdef%' '}' '

local comp_prog comp_func compoptions flag_noquote
Expand Down
13 changes: 11 additions & 2 deletions lib/core-syntax.sh
Expand Up @@ -4581,9 +4581,18 @@ function ble/syntax/completion-context/.check-prefix/ctx:quote/.check-container-

local wlen2=${nest[1]}; ((wlen2>=0)) || return
local wbeg2=$((wlen2<0?wlen2:inest-wlen2))

if ble/syntax:bash/simple-word/is-simple-or-open-simple "${text:wbeg2:index-wbeg2}"; then
ble/syntax/completion-context/.add argument "$wbeg2"
local wt=${nest[2]}
[[ ${_ble_syntax_bash_command_EndWtype[wt]} ]] &&
wt=${_ble_syntax_bash_command_EndWtype[wt]}
if ((wt==CTX_CMDI)); then
ble/syntax/completion-context/.add command "$wbeg2"
elif ((wt==CTX_ARGI||wt==CTX_ARGVI||wt==CTX_ARGEI||wt==CTX_FARGI2||wt==CTX_CARGI2)); then
ble/syntax/completion-context/.add argument "$wbeg2"
elif ((wt==CTX_CPATI)); then # case pattern の内部
#ble/syntax/completion-context/.add file "$wbeg2"
return
fi
fi
}

Expand Down

0 comments on commit 6987ae8

Please sign in to comment.