Rename previous-history to prev-history

previous-history is still supported for backward compatibility
pull/3093/head
Junegunn Choi 1 year ago
parent 7812c64a31
commit 0ad30063ff
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

@ -482,7 +482,7 @@ Use black background
.BI "--history=" "HISTORY_FILE"
Load search history from the specified file and update the file on completion.
When enabled, \fBCTRL-N\fR and \fBCTRL-P\fR are automatically remapped to
\fBnext-history\fR and \fBprevious-history\fR.
\fBnext-history\fR and \fBprev-history\fR.
.TP
.BI "--history-size=" "N"
Maximum number of entries in the history file (default: 1000). The file is
@ -978,6 +978,7 @@ A key or an event can be bound to one or more of the following actions.
\fBpage-up\fR \fIpgup\fR
\fBhalf-page-down\fR
\fBhalf-page-up\fR
\fBprev-history\fR (\fIctrl-p\fR on \fB--history\fR)
\fBpreview(...)\fR (see below for the details)
\fBpreview-down\fR \fIshift-down\fR
\fBpreview-up\fR \fIshift-up\fR
@ -987,7 +988,6 @@ A key or an event can be bound to one or more of the following actions.
\fBpreview-half-page-up\fR
\fBpreview-bottom\fR
\fBpreview-top\fR
\fBprevious-history\fR (\fIctrl-p\fR on \fB--history\fR)
\fBprint-query\fR (print query and exit)
\fBput\fR (put the character to the prompt)
\fBrefresh-preview\fR

@ -1060,8 +1060,8 @@ func parseKeymap(keymap map[tui.Event][]*action, str string) {
appendAction(actHalfPageUp)
case "half-page-down":
appendAction(actHalfPageDown)
case "previous-history":
appendAction(actPreviousHistory)
case "prev-history", "previous-history":
appendAction(actPrevHistory)
case "next-history":
appendAction(actNextHistory)
case "toggle-preview":
@ -1805,7 +1805,7 @@ func postProcessOptions(opts *Options) {
// Default actions for CTRL-N / CTRL-P when --history is set
if opts.History != nil {
if _, prs := opts.Keymap[tui.CtrlP.AsEvent()]; !prs {
opts.Keymap[tui.CtrlP.AsEvent()] = toActions(actPreviousHistory)
opts.Keymap[tui.CtrlP.AsEvent()] = toActions(actPrevHistory)
}
if _, prs := opts.Keymap[tui.CtrlN.AsEvent()]; !prs {
opts.Keymap[tui.CtrlN.AsEvent()] = toActions(actNextHistory)

@ -354,10 +354,10 @@ func TestDefaultCtrlNP(t *testing.T) {
f.Close()
hist := "--history=" + f.Name()
check([]string{hist}, tui.CtrlN, actNextHistory)
check([]string{hist}, tui.CtrlP, actPreviousHistory)
check([]string{hist}, tui.CtrlP, actPrevHistory)
check([]string{hist, "--bind=ctrl-n:accept"}, tui.CtrlN, actAccept)
check([]string{hist, "--bind=ctrl-n:accept"}, tui.CtrlP, actPreviousHistory)
check([]string{hist, "--bind=ctrl-n:accept"}, tui.CtrlP, actPrevHistory)
check([]string{hist, "--bind=ctrl-p:accept"}, tui.CtrlN, actNextHistory)
check([]string{hist, "--bind=ctrl-p:accept"}, tui.CtrlP, actAccept)

@ -315,7 +315,7 @@ const (
actPreviewPageDown
actPreviewHalfPageUp
actPreviewHalfPageDown
actPreviousHistory
actPrevHistory
actNextHistory
actExecute
actExecuteSilent
@ -2859,7 +2859,7 @@ func (t *Terminal) Loop() {
prefix := copySlice(t.input[:t.cx])
t.input = append(append(prefix, event.Char), t.input[t.cx:]...)
t.cx++
case actPreviousHistory:
case actPrevHistory:
if t.history != nil {
t.history.override(string(t.input))
t.input = trimQuery(t.history.previous())

Loading…
Cancel
Save