2018-06-07 11:49:03 +08:00
|
|
|
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# Fetch Suggestion #
|
|
|
|
#--------------------------------------------------------------------#
|
|
|
|
# Loops through all specified strategies and returns a suggestion
|
|
|
|
# from the first strategy to provide one.
|
|
|
|
#
|
|
|
|
|
|
|
|
_zsh_autosuggest_fetch_suggestion() {
|
|
|
|
typeset -g suggestion
|
|
|
|
local -a strategies
|
2018-06-19 01:47:27 +08:00
|
|
|
local strategy
|
2018-06-07 11:49:03 +08:00
|
|
|
|
|
|
|
# Ensure we are working with an array
|
|
|
|
strategies=(${=ZSH_AUTOSUGGEST_STRATEGY})
|
|
|
|
|
|
|
|
for strategy in $strategies; do
|
|
|
|
# Try to get a suggestion from this strategy
|
|
|
|
_zsh_autosuggest_strategy_$strategy "$1"
|
|
|
|
|
2018-11-24 01:18:15 +08:00
|
|
|
# Ensure the suggestion matches the prefix
|
|
|
|
[[ "$suggestion" != "$1"* ]] && unset suggestion
|
|
|
|
|
|
|
|
# Break once we've found a valid suggestion
|
2018-06-07 11:49:03 +08:00
|
|
|
[[ -n "$suggestion" ]] && break
|
|
|
|
done
|
|
|
|
}
|