Skip to content

Commit

Permalink
syntax: fix a bug that arguments of "eval" are not highlighted
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Feb 7, 2020
1 parent 1070aba commit 38a7fc7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
17 changes: 12 additions & 5 deletions lib/core-complete.sh
Expand Up @@ -655,15 +655,22 @@ function ble/complete/source:command/gen {
# [[ :$comp_type: == *:a:* ]] && local COMPS=${COMPS::1} COMPV=${COMPV::1}
# compgen -A directory -S / -- "$compv_quoted"
#
local ret
ble/complete/source:file/.construct-pathname-pattern "$COMPV"
ble/complete/util/eval-pathname-expansion "$ret/"
((${#ret[@]})) && printf '%s\n' "${ret[@]}"
if [[ $arg != *D* ]]; then
local ret
ble/complete/source:file/.construct-pathname-pattern "$COMPV"
ble/complete/util/eval-pathname-expansion "$ret/"
((${#ret[@]})) && printf '%s\n' "${ret[@]}"
fi
}
## ble/complete/source:command arg
## @param[in] arg
## arg に D が含まれている時、
## ディレクトリ名の列挙を抑制する事を表します。
function ble/complete/source:command {
[[ $comps_flags == *v* ]] || return 1
[[ ! $COMPV ]] && shopt -q no_empty_cmd_completion && return 1
[[ $COMPV =~ ^.+/ ]] && COMP_PREFIX=${BASH_REMATCH[0]}
local arg=$1

# Try progcomp by "complete -I"
if ((_ble_bash>=50000)); then
Expand All @@ -685,7 +692,7 @@ function ble/complete/source:command {

local cand arr i=0
local compgen
ble/util/assign compgen 'ble/complete/source:command/gen'
ble/util/assign compgen 'ble/complete/source:command/gen "$arg"'
[[ $compgen ]] || return 1
ble/util/assign-array arr 'sort -u <<< "$compgen"' # 1 fork/exec
for cand in "${arr[@]}"; do
Expand Down
8 changes: 4 additions & 4 deletions lib/core-syntax.sh
Expand Up @@ -4358,7 +4358,7 @@ _ble_syntax_bash_complete_check_prefix[CTX_VALQ]='inside-argument file'
_ble_syntax_bash_complete_check_prefix[CTX_CONDI]='inside-argument file'
_ble_syntax_bash_complete_check_prefix[CTX_CONDQ]='inside-argument file'
_ble_syntax_bash_complete_check_prefix[CTX_ARGVI]='inside-argument variable:='
_ble_syntax_bash_complete_check_prefix[CTX_ARGEI]='inside-argument variable:= command file'
_ble_syntax_bash_complete_check_prefix[CTX_ARGEI]='inside-argument variable:= command:D file'
function ble/syntax/completion-context/.check-prefix/ctx:inside-argument {
if ((wlen>=0)); then
local source
Expand Down Expand Up @@ -4430,7 +4430,7 @@ function ble/syntax/completion-context/.check-prefix/ctx:next-argument {
elif ((ctx==CTX_ARGVX)); then
source=(variable:=)
elif ((ctx==CTX_ARGEX)); then
source=(variable:= command file)
source=(variable:= command:D file)
else
source=(file)
fi
Expand Down Expand Up @@ -5386,7 +5386,7 @@ function ble/highlight/layer:syntax/word/.update-attributes/.proc {
local -a value; value=("${ret[@]}")
fi

if ((ext&&(wtype==CTX_CMDI||wtype==CTX_ARGI||wtype==CTX_RDRF||wtype==CTX_RDRS||wtype==CTX_VALI))); then
if ((ext&&(wtype==CTX_CMDI||wtype==CTX_ARGI||wtype==CTX_ARGEI||wtype==CTX_RDRF||wtype==CTX_RDRS||wtype==CTX_VALI))); then
# failglob 等の理由で展開に失敗した場合
type=$ATTR_ERR
elif (((wtype==CTX_RDRF||wtype==CTX_RDRD)&&${#value[@]}>=2)); then
Expand All @@ -5399,7 +5399,7 @@ function ble/highlight/layer:syntax/word/.update-attributes/.proc {
fi
elif ((wtype==ATTR_FUNCDEF||wtype==ATTR_ERR)); then
((type=wtype))
elif ((wtype==CTX_ARGI||wtype==CTX_RDRF||wtype==CTX_RDRS||wtype==ATTR_VAR||wtype==CTX_VALI)); then
elif ((wtype==CTX_ARGI||wtype==CTX_ARGEI||wtype==CTX_RDRF||wtype==CTX_RDRS||wtype==ATTR_VAR||wtype==CTX_VALI)); then
ble/syntax/highlight/filetype "$value"

# check values
Expand Down

0 comments on commit 38a7fc7

Please sign in to comment.