Add refresh-preview action

pull/2100/head
Junegunn Choi 4 years ago
parent a7aa08ce07
commit c33258832e
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

@ -696,6 +696,7 @@ A key or an event can be bound to one or more of the following actions.
\fBpreview-page-up\fR
\fBprevious-history\fR (\fIctrl-p\fR on \fB--history\fR)
\fBprint-query\fR (print query and exit)
\fBrefresh-preview\fR
\fBreload(...)\fR (see below for the details)
\fBreplace-query\fR (replace query string with the current selection)
\fBselect-all\fR (select all matches)

@ -756,6 +756,8 @@ func parseKeymap(keymap map[int][]action, str string) {
appendAction(actAcceptNonEmpty)
case "print-query":
appendAction(actPrintQuery)
case "refresh-preview":
appendAction(actRefreshPreview)
case "replace-query":
appendAction(actReplaceQuery)
case "backward-char":

@ -224,6 +224,7 @@ const (
actJump
actJumpAccept
actPrintQuery
actRefreshPreview
actReplaceQuery
actToggleSort
actTogglePreview
@ -1659,6 +1660,14 @@ func (t *Terminal) Loop() {
t.killPreview(code)
}
refreshPreview := func() {
if t.isPreviewEnabled() {
_, list := t.buildPlusList(t.preview.command, false)
t.cancelPreview()
t.previewBox.Set(reqPreviewEnqueue, list)
}
}
go func() {
var focusedIndex int32 = minItem.Index()
var version int64 = -1
@ -1685,11 +1694,7 @@ func (t *Terminal) Loop() {
if focusedIndex != currentIndex || version != t.version {
version = t.version
focusedIndex = currentIndex
if t.isPreviewEnabled() {
_, list := t.buildPlusList(t.preview.command, false)
t.cancelPreview()
t.previewBox.Set(reqPreviewEnqueue, list)
}
refreshPreview()
}
case reqJump:
if t.merger.Length() == 0 {
@ -1847,6 +1852,8 @@ func (t *Terminal) Loop() {
}
case actPrintQuery:
req(reqPrintQuery)
case actRefreshPreview:
refreshPreview()
case actReplaceQuery:
if t.cy >= 0 && t.cy < t.merger.Length() {
t.input = t.merger.Get(t.cy).item.text.ToRunes()

Loading…
Cancel
Save