summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2020-06-20 22:04:09 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2020-06-20 22:04:09 +0900
commitc33258832eeb855c0a269980aef89c37a7e13d6a (patch)
tree6e6047077aeceea7e10bb5832d06d1f14d10edf3
parenta7aa08ce07e2c21ac9ed8621e46cbe989228f3cd (diff)
Add refresh-preview action
-rw-r--r--man/man1/fzf.11
-rw-r--r--src/options.go2
-rw-r--r--src/terminal.go17
3 files changed, 15 insertions, 5 deletions
diff --git a/man/man1/fzf.1 b/man/man1/fzf.1
index 9f17177a..d1257c84 100644
--- a/man/man1/fzf.1
+++ b/man/man1/fzf.1
@@ -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)
diff --git a/src/options.go b/src/options.go
index 2979da6b..cb070ec2 100644
--- a/src/options.go
+++ b/src/options.go
@@ -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":
diff --git a/src/terminal.go b/src/terminal.go
index a5dfe491..56da73a9 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -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()