diff --git a/src/suggestion.zsh b/src/suggestion.zsh index 7ef2def..786d8b8 100644 --- a/src/suggestion.zsh +++ b/src/suggestion.zsh @@ -14,7 +14,8 @@ _zsh_autosuggest_suggestion() { # Get all history event numbers (reversed) that correspond to history # entries that match pattern $prefix* - local history_match_keys=(${(k)history[(R)$prefix*]}) + local history_match_keys + history_match_keys=(${(k)history[(R)$prefix*]}) # By default we use the first history number (most recent history entry) local history_key="$history_match_keys[1]" @@ -22,7 +23,7 @@ _zsh_autosuggest_suggestion() { # If matching on the previous command is enabled ... if (( ${+ZSH_AUTOSUGGEST_MATCH_PREV_CMD} )); then # Get the previously executed command - local prev_cmd=$(_zsh_autosuggest_prev_cmd) + local prev_cmd="$(_zsh_autosuggest_prev_cmd)" prev_cmd="$(_zsh_autosuggest_escape_command_prefix $prev_cmd)" # Iterate up to the first 200 history event numbers that match $prefix diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 45d60d1..9194ab5 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -312,7 +312,8 @@ _zsh_autosuggest_suggestion() { # Get all history event numbers (reversed) that correspond to history # entries that match pattern $prefix* - local history_match_keys=(${(k)history[(R)$prefix*]}) + local history_match_keys + history_match_keys=(${(k)history[(R)$prefix*]}) # By default we use the first history number (most recent history entry) local history_key="$history_match_keys[1]" @@ -320,7 +321,7 @@ _zsh_autosuggest_suggestion() { # If matching on the previous command is enabled ... if (( ${+ZSH_AUTOSUGGEST_MATCH_PREV_CMD} )); then # Get the previously executed command - local prev_cmd=$(_zsh_autosuggest_prev_cmd) + local prev_cmd="$(_zsh_autosuggest_prev_cmd)" prev_cmd="$(_zsh_autosuggest_escape_command_prefix $prev_cmd)" # Iterate up to the first 200 history event numbers that match $prefix