From ca086b8999961a39452697867c991767b2ed8165 Mon Sep 17 00:00:00 2001 From: Guido van Steen Date: Sat, 25 Jun 2011 05:43:33 -0700 Subject: [PATCH] fix down-history after reaching the top of history --- history-substring-search.zsh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/history-substring-search.zsh b/history-substring-search.zsh index 2b0dcb8..30c2527 100644 --- a/history-substring-search.zsh +++ b/history-substring-search.zsh @@ -354,10 +354,13 @@ _history-substring-search-up-history() { # if [[ -z $_history_substring_search_query ]]; then - if [[ $HISTNO -gt 1 ]]; then - zle up-history - else + # we have reached the absolute top of history + if [[ $HISTNO -eq 1 ]]; then BUFFER='' + + # going up from somewhere below the top of history + else + zle up-history fi return true @@ -373,10 +376,14 @@ _history-substring-search-down-history() { # if [[ -z $_history_substring_search_query ]]; then - if [[ $HISTNO -le $#history ]]; then - zle down-history + # going down from the absolute top of history + if [[ $HISTNO -eq 1 && -z $BUFFER ]]; then + BUFFER=${history[1]} + _history_substring_search_move_cursor_eol=true + + # going down from somewhere above the bottom of history else - BUFFER='' + zle down-history fi return true