make down-search() and up-search() logic symmetric
This commit is contained in:
parent
810095f097
commit
15f63dea7f
1 changed files with 60 additions and 40 deletions
|
|
@ -319,10 +319,28 @@ function _history-substring-search-begin() {
|
||||||
_history_substring_search_matches_count_sans=$(( _history_substring_search_matches_count - 1 ))
|
_history_substring_search_matches_count_sans=$(( _history_substring_search_matches_count - 1 ))
|
||||||
|
|
||||||
#
|
#
|
||||||
# initial value of $_history_substring_search_match_index, which
|
# If $_history_substring_search_match_index is equal to
|
||||||
# can only be decreased by the history-substring-search-* widgets.
|
# $_history_substring_search_matches_count_plus, this indicates that we
|
||||||
|
# are beyond the beginning of $_history_substring_search_matches.
|
||||||
#
|
#
|
||||||
_history_substring_search_match_index=$_history_substring_search_matches_count_plus
|
# If $_history_substring_search_match_index is equal to 0, this indicates
|
||||||
|
# that we are beyond the end of $_history_substring_search_matches.
|
||||||
|
#
|
||||||
|
# If we have initially pressed "up" we have to initialize
|
||||||
|
# $_history_substring_search_match_index to
|
||||||
|
# $_history_substring_search_matches_count_plus so that it will be
|
||||||
|
# decreased to $_history_substring_search_matches_count.
|
||||||
|
#
|
||||||
|
# If we have initially pressed "down" we have to initialize
|
||||||
|
# $_history_substring_search_match_index to
|
||||||
|
# $_history_substring_search_matches_count so that it will be increased to
|
||||||
|
# $_history_substring_search_matches_count_plus.
|
||||||
|
#
|
||||||
|
if [[ $WIDGET == history-substring-search-down ]]; then
|
||||||
|
_history_substring_search_match_index=$_history_substring_search_matches_count
|
||||||
|
else
|
||||||
|
_history_substring_search_match_index=$_history_substring_search_matches_count_plus
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -465,23 +483,29 @@ function _history-substring-search-up-search() {
|
||||||
_history_substring_search_move_cursor_eol=true
|
_history_substring_search_move_cursor_eol=true
|
||||||
|
|
||||||
#
|
#
|
||||||
# Highlight matches during a history-substring-search:
|
# Highlight matches during history-substring-up-search:
|
||||||
#
|
#
|
||||||
# * $_history_substring_search_matches: the current list of matches
|
# The following constants have been initialized in
|
||||||
# * $_history_substring_search_matches_count: the current number of matches
|
# _history-substring-search-up/down-search():
|
||||||
# * $_history_substring_search_matches_count_plus: the current number of matches + 1
|
|
||||||
# * $_history_substring_search_matches_count_sans: the current number of matches - 1
|
|
||||||
# * $_history_substring_search_match_index: the number of the current match
|
|
||||||
#
|
#
|
||||||
# The range of values that $_history_substring_search_match_index
|
# $_history_substring_search_matches is the current list of matches
|
||||||
# can take is: [0, $_history_substring_search_matches_count_plus].
|
# $_history_substring_search_matches_count is the current number of matches
|
||||||
# A value of 0 indicates that we are beyond the end of
|
# $_history_substring_search_matches_count_plus is the current number of matches + 1
|
||||||
|
# $_history_substring_search_matches_count_sans is the current number of matches - 1
|
||||||
|
# $_history_substring_search_match_index is the index of the current match
|
||||||
|
#
|
||||||
|
# The range of values that $_history_substring_search_match_index can take
|
||||||
|
# is: [0, $_history_substring_search_matches_count_plus]. A value of 0
|
||||||
|
# indicates that we are beyond the end of
|
||||||
# $_history_substring_search_matches. A value of
|
# $_history_substring_search_matches. A value of
|
||||||
# $_history_substring_search_matches_count_plus indicates that we
|
# $_history_substring_search_matches_count_plus indicates that we are beyond
|
||||||
# are beyond the beginning of $_history_substring_search_matches.
|
# the beginning of $_history_substring_search_matches.
|
||||||
#
|
#
|
||||||
# The initial value of $_history_substring_search_match_index is
|
# In _history-substring-search-up-search() the initial value of
|
||||||
# $_history_substring_search_matches_count_plus.
|
# $_history_substring_search_match_index is
|
||||||
|
# $_history_substring_search_matches_count_plus. This value is set in
|
||||||
|
# _history-substring-search-begin(). _history-substring-search-up-search()
|
||||||
|
# will initially decrease it to $_history_substring_search_matches_count.
|
||||||
#
|
#
|
||||||
if [[ $_history_substring_search_match_index -ge 2 ]]; then
|
if [[ $_history_substring_search_match_index -ge 2 ]]; then
|
||||||
#
|
#
|
||||||
|
|
@ -538,36 +562,32 @@ function _history-substring-search-down-search() {
|
||||||
_history_substring_search_move_cursor_eol=true
|
_history_substring_search_move_cursor_eol=true
|
||||||
|
|
||||||
#
|
#
|
||||||
# Highlight matches during a history-substring-search:
|
# Highlight matches during history-substring-up-search:
|
||||||
#
|
#
|
||||||
# $_history_substring_search_matches: the current list of matches
|
# The following constants have been initialized in
|
||||||
# $_history_substring_search_matches_count: the current number of matches
|
# _history-substring-search-up/down-search():
|
||||||
# $_history_substring_search_matches_count_plus: the current number of matches + 1
|
|
||||||
# $_history_substring_search_matches_count_sans: the current number of matches - 1
|
|
||||||
# $_history_substring_search_match_index: the number of the current match
|
|
||||||
#
|
#
|
||||||
# The range of values that $_history_substring_search_match_index
|
# $_history_substring_search_matches is the current list of matches
|
||||||
# can take is: [0, $_history_substring_search_matches_count_plus].
|
# $_history_substring_search_matches_count is the current number of matches
|
||||||
# A value of 0 indicates that we are beyond the end of
|
# $_history_substring_search_matches_count_plus is the current number of matches + 1
|
||||||
|
# $_history_substring_search_matches_count_sans is the current number of matches - 1
|
||||||
|
# $_history_substring_search_match_index is the index of the current match
|
||||||
|
#
|
||||||
|
# The range of values that $_history_substring_search_match_index can take
|
||||||
|
# is: [0, $_history_substring_search_matches_count_plus]. A value of 0
|
||||||
|
# indicates that we are beyond the end of
|
||||||
# $_history_substring_search_matches. A value of
|
# $_history_substring_search_matches. A value of
|
||||||
# $_history_substring_search_matches_count_plus indicates that we
|
# $_history_substring_search_matches_count_plus indicates that we are beyond
|
||||||
# are beyond the beginning of $_history_substring_search_matches.
|
# the beginning of $_history_substring_search_matches.
|
||||||
#
|
#
|
||||||
# The initial value of $_history_substring_search_match_index is
|
# In _history-substring-search-down-search() the initial value of
|
||||||
|
# $_history_substring_search_match_index is
|
||||||
|
# $_history_substring_search_matches_count. This value is set in
|
||||||
|
# _history-substring-search-begin().
|
||||||
|
# _history-substring-search-down-search() will initially increase it to
|
||||||
# $_history_substring_search_matches_count_plus.
|
# $_history_substring_search_matches_count_plus.
|
||||||
#
|
#
|
||||||
if [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count_plus ]]; then
|
if [[ $_history_substring_search_match_index -le $_history_substring_search_matches_count_sans ]]; then
|
||||||
#
|
|
||||||
# DOWN was pressed immediately. $_history_substring_search_match_index is
|
|
||||||
# still equal to $_history_substring_search_match_number_plus.
|
|
||||||
# However, there is no highlighting yet:
|
|
||||||
#
|
|
||||||
# 1. We have to use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
|
|
||||||
# to highlight the current buffer.
|
|
||||||
#
|
|
||||||
_history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND
|
|
||||||
|
|
||||||
elif [[ $_history_substring_search_match_index -le $_history_substring_search_matches_count_sans ]]; then
|
|
||||||
#
|
#
|
||||||
# Highlight the next match:
|
# Highlight the next match:
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue