mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
more zsh style code
This commit is contained in:
parent
f06305c948
commit
491aff3a51
2 changed files with 6 additions and 0 deletions
|
@ -65,8 +65,11 @@ _zsh_autosuggest_strategy_predefined() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
setopt EXTENDED_GLOB
|
setopt EXTENDED_GLOB
|
||||||
local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}"
|
local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}"
|
||||||
|
|
||||||
|
# search the history at first
|
||||||
local result="${history[(r)${prefix}*]}"
|
local result="${history[(r)${prefix}*]}"
|
||||||
|
|
||||||
|
# search the predefine files if nothing found in history
|
||||||
if [[ -z "$result" ]]; then
|
if [[ -z "$result" ]]; then
|
||||||
if (( ! ${+_ZSH_AUTOSUGGEST_PREDEFINE} )); then
|
if (( ! ${+_ZSH_AUTOSUGGEST_PREDEFINE} )); then
|
||||||
typeset -g _ZSH_AUTOSUGGEST_PREDEFINE=()
|
typeset -g _ZSH_AUTOSUGGEST_PREDEFINE=()
|
||||||
|
|
|
@ -631,8 +631,11 @@ _zsh_autosuggest_strategy_predefined() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
setopt EXTENDED_GLOB
|
setopt EXTENDED_GLOB
|
||||||
local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}"
|
local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}"
|
||||||
|
|
||||||
|
# search the history at first
|
||||||
local result="${history[(r)${prefix}*]}"
|
local result="${history[(r)${prefix}*]}"
|
||||||
|
|
||||||
|
# search the predefine files if nothing found in history
|
||||||
if [[ -z "$result" ]]; then
|
if [[ -z "$result" ]]; then
|
||||||
if (( ! ${+_ZSH_AUTOSUGGEST_PREDEFINE} )); then
|
if (( ! ${+_ZSH_AUTOSUGGEST_PREDEFINE} )); then
|
||||||
typeset -g _ZSH_AUTOSUGGEST_PREDEFINE=()
|
typeset -g _ZSH_AUTOSUGGEST_PREDEFINE=()
|
||||||
|
|
Loading…
Reference in a new issue