mirror of
https://github.com/zsh-users/zsh-history-substring-search.git
synced 2026-11-11 03:41:47 -05:00
cursor movements should not make $BUFFER new query
Suppose you have just pressed "arrow-up", and you get a single-line in your terminal. You move your cursor into $BUFFER. After this the edited $BUFFER becomes the new search string. That breaks the searching model.
This commit is contained in:
@@ -51,7 +51,7 @@ HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold'
|
|||||||
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'
|
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'
|
||||||
|
|
||||||
history-substring-search-begin() {
|
history-substring-search-begin() {
|
||||||
if [[ $LASTWIDGET != history-substring-search-* ]]; then
|
if [[ $LASTWIDGET != history-substring-search-* && (-z $BUFFER || $BUFFER != $history_substring_search_result) ]]; then
|
||||||
# $BUFFER contains the text that is in the command-line currently.
|
# $BUFFER contains the text that is in the command-line currently.
|
||||||
# we put an extra "\\" before meta characters such as "\(" and "\)",
|
# we put an extra "\\" before meta characters such as "\(" and "\)",
|
||||||
# so that they become "\\\(" and "\\\)"
|
# so that they become "\\\(" and "\\\)"
|
||||||
@@ -88,7 +88,7 @@ history-substring-search-highlight() {
|
|||||||
_zsh_highlight-zle-buffer
|
_zsh_highlight-zle-buffer
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $history_substring_search_query != "" ]]; then
|
if [[ -n $history_substring_search_query ]]; then
|
||||||
# history_substring_search_query_escaped string was not empty: highlight it
|
# history_substring_search_query_escaped string was not empty: highlight it
|
||||||
# among other things, the following expression yields a variable $MEND,
|
# among other things, the following expression yields a variable $MEND,
|
||||||
# which indicates the end position of the first occurrence of
|
# which indicates the end position of the first occurrence of
|
||||||
@@ -101,6 +101,8 @@ history-substring-search-highlight() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
history-substring-search-end() {
|
history-substring-search-end() {
|
||||||
|
history_substring_search_result=$BUFFER
|
||||||
|
|
||||||
# "zle .end-of-line" does not move CURSOR to the final end of line in
|
# "zle .end-of-line" does not move CURSOR to the final end of line in
|
||||||
# multi-line buffers.
|
# multi-line buffers.
|
||||||
CURSOR=${#BUFFER}
|
CURSOR=${#BUFFER}
|
||||||
|
|||||||
Reference in New Issue
Block a user