Revert "Declare global variables"

This reverts commit b554feb7ba.
This commit is contained in:
Alyssa Ross 2016-11-02 01:23:44 +00:00
parent d26aaa6594
commit 3fa98998c5

View file

@ -42,10 +42,10 @@
# configuration variables # configuration variables
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold' HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold'
typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold' HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'
typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i'
typeset -g HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE='' HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=''
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# the main ZLE widgets # the main ZLE widgets
@ -178,11 +178,8 @@ fi
_history-substring-search-begin() { _history-substring-search-begin() {
setopt localoptions extendedglob setopt localoptions extendedglob
typeset -g _history_substring_search_refresh_display= _history_substring_search_refresh_display=
typeset -g _history_substring_search_query_highlight= _history_substring_search_query_highlight=
# Declare global variables that will be referenced in this function
typeset -g BUFFER MATCH
# #
# If the buffer is the same as the previously displayed history substring # If the buffer is the same as the previously displayed history substring
@ -196,7 +193,7 @@ _history-substring-search-begin() {
# #
# Clear the previous result. # Clear the previous result.
# #
typeset -g _history_substring_search_result='' _history_substring_search_result=''
if [[ -z $BUFFER ]]; then if [[ -z $BUFFER ]]; then
# #
@ -205,14 +202,14 @@ _history-substring-search-begin() {
# speed things up a little. # speed things up a little.
# #
_history_substring_search_query= _history_substring_search_query=
typeset -g _history_substring_search_raw_matches=() _history_substring_search_raw_matches=()
else else
# #
# For the purpose of highlighting we keep a copy of the original # For the purpose of highlighting we keep a copy of the original
# query string. # query string.
# #
typeset -g _history_substring_search_query=$BUFFER _history_substring_search_query=$BUFFER
# #
# $BUFFER contains the text that is in the command-line currently. # $BUFFER contains the text that is in the command-line currently.
@ -228,7 +225,7 @@ _history-substring-search-begin() {
# (R) returns values in reverse older, so the index of the youngest # (R) returns values in reverse older, so the index of the youngest
# matching history entry is at the head of the list. # matching history entry is at the head of the list.
# #
typeset -g _history_substring_search_raw_matches=(${(k)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${escaped_query}*]}) _history_substring_search_raw_matches=(${(k)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${escaped_query}*]})
fi fi
# #
@ -245,8 +242,8 @@ _history-substring-search-begin() {
# If an entry (key) is in the set (non-empty value), then we have already # If an entry (key) is in the set (non-empty value), then we have already
# added that entry to _history_substring_search_matches. # added that entry to _history_substring_search_matches.
# #
typeset -g _history_substring_search_raw_match_index=0 _history_substring_search_raw_match_index=0
typeset -g _history_substring_search_matches=() _history_substring_search_matches=()
unset _history_substring_search_unique_filter unset _history_substring_search_unique_filter
typeset -A -g _history_substring_search_unique_filter typeset -A -g _history_substring_search_unique_filter
@ -269,9 +266,9 @@ _history-substring-search-begin() {
# decremented to 0. # decremented to 0.
# #
if [[ $WIDGET == history-substring-search-down ]]; then if [[ $WIDGET == history-substring-search-down ]]; then
typeset -g _history_substring_search_match_index=1 _history_substring_search_match_index=1
else else
typeset -g _history_substring_search_match_index=0 _history_substring_search_match_index=0
fi fi
} }
@ -284,7 +281,7 @@ _history-substring-search-end() {
# existing highlights and moving the cursor to the end of the result buffer # existing highlights and moving the cursor to the end of the result buffer
if [[ $_history_substring_search_refresh_display -eq 1 ]]; then if [[ $_history_substring_search_refresh_display -eq 1 ]]; then
region_highlight=() region_highlight=()
typeset -g CURSOR=${#BUFFER} CURSOR=${#BUFFER}
fi fi
# highlight command line using zsh-syntax-highlighting # highlight command line using zsh-syntax-highlighting
@ -297,7 +294,6 @@ _history-substring-search-end() {
# indicates the begin position + 1 of the first occurrence # indicates the begin position + 1 of the first occurrence
# of _history_substring_search_query in $BUFFER. # of _history_substring_search_query in $BUFFER.
# #
typeset -g MBEGIN MEND
: ${(S)BUFFER##(#m$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)($_history_substring_search_query##)} : ${(S)BUFFER##(#m$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)($_history_substring_search_query##)}
local begin=$(( MBEGIN - 1 )) local begin=$(( MBEGIN - 1 ))
local end=$(( begin + $#_history_substring_search_query )) local end=$(( begin + $#_history_substring_search_query ))