diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Functions/Zle/down-line-or-beginning-search | 22 | ||||
-rw-r--r-- | Functions/Zle/up-line-or-beginning-search | 21 |
3 files changed, 32 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog index bc9efef7a..01473248d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2002-04-04 Oliver Kiddle <opk@zsh.org> + * 16933; based on 16011 (Martin Ebourne) and 16906 (Bart): + Functions/Zle/up-line-or-beginning-search, + Functions/Zle/down-line-or-beginning-search: + more sophisticated versions of these functions + * 16923: Completion/Base/Completer/_all_matches, Doc/Zsh/compsys.yo: add insert style to insert all matches instead of adding as a match diff --git a/Functions/Zle/down-line-or-beginning-search b/Functions/Zle/down-line-or-beginning-search index 881150171..8a8ed8994 100644 --- a/Functions/Zle/down-line-or-beginning-search +++ b/Functions/Zle/down-line-or-beginning-search @@ -1,13 +1,19 @@ # Like down-line-or-search, but uses the whole line prefix up to the # cursor position for searching forwards. -if [[ $LASTWIDGET != $WIDGET ]] +if [[ ${+NUMERIC} -eq 0 && + ( $LASTWIDGET = $__searching || $RBUFFER != *$'\n'* ) ]] then - if [[ $LBUFFER == *$'\n'* ]] - then - __last_down_line=down-line-or-history - else - __last_down_line=history-beginning-search-forward - fi + [[ $LASTWIDGET = $__searching ]] && CURSOR=$__savecursor + __searching=$WIDGET + __savecursor=$CURSOR + if zle .history-beginning-search-forward; then + [[ $RBUFFER = *$'\n'* ]] || + zstyle -T ':zle:down-line-or-beginning-search' leave-cursor && + zle .end-of-line + return + fi + [[ $RBUFFER = *$'\n'* ]] || return fi -zle .${__last_down_line:-beep} +__searching='' +zle .down-line-or-history diff --git a/Functions/Zle/up-line-or-beginning-search b/Functions/Zle/up-line-or-beginning-search index 12f2edaae..22d5183be 100644 --- a/Functions/Zle/up-line-or-beginning-search +++ b/Functions/Zle/up-line-or-beginning-search @@ -1,13 +1,18 @@ # Like up-line-or-search, but uses the whole line prefix up to the # cursor position for searching backwards. -if [[ $LASTWIDGET != $WIDGET ]] +if [[ $LBUFFER == *$'\n'* ]]; then + zle .up-line-or-history + __searching='' +elif [[ -n $PREBUFFER ]] && + zstyle -t ':zle:up-line-or-beginning-search' edit-buffer then - if [[ $LBUFFER == *$'\n'* ]] - then - __last_up_line=up-line-or-history - else - __last_up_line=history-beginning-search-backward - fi + zle .push-line-or-edit +else + [[ $LASTWIDGET = $__searching ]] && CURSOR=$__savecursor + __savecursor=$CURSOR + __searching=$WIDGET + zle .history-beginning-search-backward + zstyle -T ':zle:up-line-or-beginning-search' leave-cursor && + zle .end-of-line fi -zle .${__last_up_line:-beep} |