From 491aff3a51b73a0fa1d0c91083df528b37edd057 Mon Sep 17 00:00:00 2001 From: skywind3000 Date: Thu, 8 Feb 2018 02:55:05 +0800 Subject: [PATCH] more zsh style code --- src/strategies/predefined.zsh | 3 +++ zsh-autosuggestions.zsh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/strategies/predefined.zsh b/src/strategies/predefined.zsh index 5993ff2..3b860b6 100644 --- a/src/strategies/predefined.zsh +++ b/src/strategies/predefined.zsh @@ -65,8 +65,11 @@ _zsh_autosuggest_strategy_predefined() { emulate -L zsh setopt EXTENDED_GLOB local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" + + # search the history at first local result="${history[(r)${prefix}*]}" + # search the predefine files if nothing found in history if [[ -z "$result" ]]; then if (( ! ${+_ZSH_AUTOSUGGEST_PREDEFINE} )); then typeset -g _ZSH_AUTOSUGGEST_PREDEFINE=() diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index e836e43..aa7b2f4 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -631,8 +631,11 @@ _zsh_autosuggest_strategy_predefined() { emulate -L zsh setopt EXTENDED_GLOB local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" + + # search the history at first local result="${history[(r)${prefix}*]}" + # search the predefine files if nothing found in history if [[ -z "$result" ]]; then if (( ! ${+_ZSH_AUTOSUGGEST_PREDEFINE} )); then typeset -g _ZSH_AUTOSUGGEST_PREDEFINE=()