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