do not wrap $HISTORY upon UP/DOWN without query
This commit is contained in:
parent
eb2d958b15
commit
654b080cd6
1 changed files with 102 additions and 71 deletions
|
|
@ -229,6 +229,19 @@ _history-substring-search-end() {
|
||||||
history-substring-search-backward() {
|
history-substring-search-backward() {
|
||||||
_history-substring-search-begin
|
_history-substring-search-begin
|
||||||
|
|
||||||
|
# When searching without a search query history-substring-search-backward should behave like
|
||||||
|
# up-history. Apart from this such a search should end with an empty BUFFER like in Fish.
|
||||||
|
if [[ $_history_substring_search_query == "" ]]; then
|
||||||
|
|
||||||
|
# We are not at the last history entry
|
||||||
|
if [[ $HISTNO -gt 1 ]]; then
|
||||||
|
zle up-history
|
||||||
|
else
|
||||||
|
[[ $#_history_substring_search_last_entry_in_history -eq 0 ]] && _history_substring_search_last_entry_in_history=$BUFFER
|
||||||
|
BUFFER=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
# Check if the UP arrow was pressed to move the cursor within a multi-line
|
# Check if the UP arrow was pressed to move the cursor within a multi-line
|
||||||
# buffer. This amounts to three tests:
|
# buffer. This amounts to three tests:
|
||||||
#
|
#
|
||||||
|
|
@ -251,6 +264,7 @@ history-substring-search-backward() {
|
||||||
zle up-line-or-history
|
zle up-line-or-history
|
||||||
_history_substring_search_move_cursor_eol=false
|
_history_substring_search_move_cursor_eol=false
|
||||||
else
|
else
|
||||||
|
# Start the actual Fisch like history search
|
||||||
if [[ $_history_substring_search_match_number -ge 2 && $_history_substring_search_match_number -le $_history_substring_search_number_of_matches_plus_one ]]; then
|
if [[ $_history_substring_search_match_number -ge 2 && $_history_substring_search_match_number -le $_history_substring_search_number_of_matches_plus_one ]]; then
|
||||||
let "_history_substring_search_match_number = $_history_substring_search_match_number - 1"
|
let "_history_substring_search_match_number = $_history_substring_search_match_number - 1"
|
||||||
BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_number]]
|
BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_number]]
|
||||||
|
|
@ -273,6 +287,7 @@ history-substring-search-backward() {
|
||||||
fi
|
fi
|
||||||
_history_substring_search_move_cursor_eol=true
|
_history_substring_search_move_cursor_eol=true
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
_history-substring-search-end
|
_history-substring-search-end
|
||||||
}
|
}
|
||||||
|
|
@ -280,6 +295,20 @@ history-substring-search-backward() {
|
||||||
history-substring-search-forward() {
|
history-substring-search-forward() {
|
||||||
_history-substring-search-begin
|
_history-substring-search-begin
|
||||||
|
|
||||||
|
# When searching without a search query history-substring-search-forward should behave like
|
||||||
|
# down-history. Apart from this such a search should end with an empty BUFFER like in Fish.
|
||||||
|
if [[ $_history_substring_search_query == "" ]]; then
|
||||||
|
|
||||||
|
# We are not at the last history entry
|
||||||
|
if [[ $#_history_substring_search_last_entry_in_history -eq 0 ]]; then
|
||||||
|
zle down-history
|
||||||
|
else
|
||||||
|
BUFFER=$_history_substring_search_last_entry_in_history
|
||||||
|
CURSOR=$#BUFFER
|
||||||
|
_history_substring_search_last_entry_in_history=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
# Check if the DOWN arrow was pressed to move the cursor within a multi-line
|
# Check if the DOWN arrow was pressed to move the cursor within a multi-line
|
||||||
# buffer. This amounts to three tests:
|
# buffer. This amounts to three tests:
|
||||||
#
|
#
|
||||||
|
|
@ -302,6 +331,7 @@ history-substring-search-forward() {
|
||||||
zle down-line-or-history
|
zle down-line-or-history
|
||||||
_history_substring_search_move_cursor_eol=false
|
_history_substring_search_move_cursor_eol=false
|
||||||
else
|
else
|
||||||
|
# Start the actual Fisch like history search
|
||||||
if [[ $_history_substring_search_match_number -eq $_history_substring_search_number_of_matches_plus_one ]]; then
|
if [[ $_history_substring_search_match_number -eq $_history_substring_search_number_of_matches_plus_one ]]; then
|
||||||
let "_history_substring_search_match_number = $_history_substring_search_match_number"
|
let "_history_substring_search_match_number = $_history_substring_search_match_number"
|
||||||
_history_substring_search_old_buffer_forward=$BUFFER
|
_history_substring_search_old_buffer_forward=$BUFFER
|
||||||
|
|
@ -327,6 +357,7 @@ history-substring-search-forward() {
|
||||||
fi
|
fi
|
||||||
_history_substring_search_move_cursor_eol=true
|
_history_substring_search_move_cursor_eol=true
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
_history-substring-search-end
|
_history-substring-search-end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue