mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2026-11-29 03:43:07 +01:00
Lots of async changes
This commit is contained in:
1 parent
38eb7cdafd
commit
ed8056c5e8
35 files changed
+384
-1133
No files matched your search
@@ -7,14 +7,19 @@
|
||||
#
|
||||
|
||||
_zsh_autosuggest_strategy_default() {
|
||||
setopt localoptions EXTENDED_GLOB
|
||||
# Reset options to defaults and enable LOCAL_OPTIONS
|
||||
emulate -L zsh
|
||||
|
||||
local prefix="${1//(#m)[\\()\[\]|*?~]/\\$MATCH}"
|
||||
# Enable globbing flags so that we can use (#m)
|
||||
setopt EXTENDED_GLOB
|
||||
|
||||
# Get the keys of the history items that match
|
||||
local -a histkeys
|
||||
histkeys=(${(k)history[(r)$prefix*]})
|
||||
# Escape backslashes and all of the glob operators so we can use
|
||||
# this string as a pattern to search the $history associative array.
|
||||
# - (#m) globbing flag enables setting references for match data
|
||||
local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}"
|
||||
|
||||
# Get the history items that match
|
||||
# - (r) subscript flag makes the pattern match on values
|
||||
suggestion="${history[(r)$prefix*]}"
|
||||
|
||||
# Give back the value of the first key
|
||||
suggestion="${history[$histkeys[1]]}"
|
||||
}
|
||||
Reference in new issue
Block a user