lib/search: fix variable scope
parent
35ecc260c2
commit
ddf75f17ac
|
|
@ -266,9 +266,11 @@ function _bash-it-search-result() {
|
|||
shift
|
||||
|
||||
local color_component color_enable color_disable color_off
|
||||
local color_sep=':' line
|
||||
|
||||
local match_color compatible_action suffix opposite_suffix
|
||||
local color_sep=':' line match matched temp
|
||||
local -i modified=0 enabled=0 len
|
||||
local -a matches=()
|
||||
|
||||
# Discard any empty arguments
|
||||
while IFS='' read -r line; do
|
||||
[[ -n "${line}" ]] && matches+=("$line")
|
||||
|
|
@ -290,18 +292,13 @@ function _bash-it-search-result() {
|
|||
color_off=''
|
||||
fi
|
||||
|
||||
local match
|
||||
local -i modified=0
|
||||
|
||||
if [[ "${#matches[@]}" -gt 0 ]]; then
|
||||
printf "${color_component}%13s${color_sep}${color_off} " "${component}"
|
||||
|
||||
for match in "${matches[@]}"; do
|
||||
local -i enabled=0
|
||||
enabled=0
|
||||
_bash-it-component-item-is-enabled "${component}" "${match}" && enabled=1
|
||||
|
||||
local match_color compatible_action suffix opposite_suffix
|
||||
|
||||
if ((enabled)); then
|
||||
match_color="${color_enable}"
|
||||
suffix="${suffix_enable}"
|
||||
|
|
@ -314,8 +311,8 @@ function _bash-it-search-result() {
|
|||
compatible_action="enable"
|
||||
fi
|
||||
|
||||
local matched="${match}${suffix}"
|
||||
local -i len="${#matched}"
|
||||
matched="${match}${suffix}"
|
||||
len="${#matched}"
|
||||
|
||||
printf '%b' "${match_color}${matched}" # print current state
|
||||
if [[ "${action}" == "${compatible_action}" ]]; then
|
||||
|
|
@ -327,7 +324,7 @@ function _bash-it-search-result() {
|
|||
modified=1
|
||||
# shellcheck disable=SC2034 # no idea if `$result` is ever used
|
||||
result=$("${action_func}" "${match}")
|
||||
local temp="color_${compatible_action}"
|
||||
temp="color_${compatible_action}"
|
||||
match_color="${!temp}"
|
||||
_bash-it-rewind "${len}"
|
||||
printf '%b' "${match_color}${match}${opposite_suffix}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue