summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-06-17 17:00:27 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-06-17 17:00:49 +0900
commited12925f7dbceaedae58b2e202f1b1f443b04ab5 (patch)
treebf771d333fd887b914cbe6518f78107e1bd0f9d4
parente0ddb97ab49b206ab350618438627b93b5c0c68f (diff)
--sync: Suppress initial render also when focus event is bound
-rw-r--r--CHANGELOG.md8
-rw-r--r--man/man1/fzf.111
-rw-r--r--src/terminal.go8
3 files changed, 21 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c633764..d7ee2748 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,13 +5,15 @@ CHANGELOG
------
- Better cache management and improved rendering for `--tail`
- Improved `--sync` behavior
- - When `--sync` is provided, fzf will not render the interface until the initial filtering and associated actions (bound to any of `start`, `load`, or `result`) are complete.
+ - When `--sync` is provided, fzf will not render the interface until the initial filtering and the associated actions (bound to any of `start`, `load`, `result`, or `focus`) are complete.
```sh
- (sleep 1; seq 1000000; sleep 1) | fzf --sync --query 5 --listen --bind start:up,load:up,result:up
+ # fzf will not render intermediate states
+ (sleep 1; seq 1000000; sleep 1) |
+ fzf --sync --query 5 --listen --bind start:up,load:up,result:up,focus:change-header:Ready
```
- GET endpoint is now available from `execute` and `transform` actions (it used to timeout due to lock conflict)
```sh
- fzf --listen --bind 'focus:transform-header:curl -s localhost:$FZF_PORT?limit=0 | jq .'
+ fzf --listen --sync --bind 'focus:transform-header:curl -s localhost:$FZF_PORT?limit=0 | jq .'
```
- Fixed crash when using `--tiebreak=end` with very long items
- Fixed mouse support on Windows
diff --git a/man/man1/fzf.1 b/man/man1/fzf.1
index 0a541ca6..3327e48c 100644
--- a/man/man1/fzf.1
+++ b/man/man1/fzf.1
@@ -889,10 +889,17 @@ e.g.
.TP
.B "--sync"
Synchronous search for multi-staged filtering. If specified, fzf will launch
-the finder only after the input stream is complete.
+the finder only after the input stream is complete and the initial filtering
+and the associated actions (bound to any of \fBstart\fR, \fBload\fR,
+\fBresult\fR, or \fBfocus\fR) are complete.
.RS
-e.g. \fBfzf --multi | fzf --sync\fR
+e.g. \fB# Avoid rendering both fzf instances at the same time
+ fzf --multi | fzf --sync
+
+ # fzf will not render intermediate states
+ (sleep 1; seq 1000000; sleep 1) |
+ fzf --sync --query 5 --listen --bind start:up,load:up,result:up,focus:change-header:Ready\fR
.RE
.TP
.B "--with-shell=STR"
diff --git a/src/terminal.go b/src/terminal.go
index 895dd8f4..c519c927 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -915,7 +915,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
}
func (t *Terminal) deferActivation() bool {
- return t.initDelay == 0 && (t.hasStartActions || t.hasLoadActions || t.hasResultActions)
+ return t.initDelay == 0 && (t.hasStartActions || t.hasLoadActions || t.hasResultActions || t.hasFocusActions)
}
func (t *Terminal) environ() []string {
@@ -1237,6 +1237,7 @@ func (t *Terminal) UpdateList(merger *Merger) {
t.cy = count - util.Min(count, t.maxItems()) + pos
}
}
+ needActivation := false
if !t.reading {
switch t.merger.Length() {
case 0:
@@ -1244,6 +1245,8 @@ func (t *Terminal) UpdateList(merger *Merger) {
if _, prs := t.keymap[zero]; prs {
t.eventChan <- zero
}
+ // --sync, only 'focus' is bound, but no items to focus
+ needActivation = t.suppress && !t.hasResultActions && !t.hasLoadActions && t.hasFocusActions
case 1:
one := tui.One.AsEvent()
if _, prs := t.keymap[one]; prs {
@@ -1257,6 +1260,9 @@ func (t *Terminal) UpdateList(merger *Merger) {
t.mutex.Unlock()
t.reqBox.Set(reqInfo, nil)
t.reqBox.Set(reqList, nil)
+ if needActivation {
+ t.reqBox.Set(reqActivate, nil)
+ }
}
func (t *Terminal) output() bool {