From 276b0065b4c1c2ec4c1af65fac3a7d111b050cb3 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 13 Jun 2025 23:58:49 +0900 Subject: [PATCH] Rename: bg-transform --- man/man1/fzf.1 | 11 +++++++++++ src/options.go | 32 ++++++++++++++++---------------- test/test_core.rb | 20 ++++++++++---------- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/man/man1/fzf.1 b/man/man1/fzf.1 index 834df205..567923fc 100644 --- a/man/man1/fzf.1 +++ b/man/man1/fzf.1 @@ -1805,6 +1805,9 @@ A key or an event can be bound to one or more of the following actions. \fBup\fR \fIctrl\-k ctrl\-p up\fR \fByank\fR \fIctrl\-y\fR +Each \fBtransform*\fR action has a corresponding \fBbg\-transform*\fR +variant that runs the command in the background. + .SS ACTION COMPOSITION Multiple actions can be chained using \fB+\fR separator. @@ -1929,6 +1932,14 @@ e.g. echo "change\-header:Invalid selection"' \fR +.SS TRANSFORM IN THE BACKGROUND + +Transform actions are synchronous, meaning fzf becomes unresponsive while the +command runs. To avoid this, each \fBtransform\-\fR action has a corresponding +\fBbg\-transform\-\fR variant that runs in the background. Unless you need to +chain multiple transform actions where later ones depend on earlier results, +prefer using the \fBbg\fR variant. + .SS PREVIEW BINDING With \fBpreview(...)\fR action, you can specify multiple different preview diff --git a/src/options.go b/src/options.go index d93492b7..6f8c6790 100644 --- a/src/options.go +++ b/src/options.go @@ -1435,7 +1435,7 @@ const ( func init() { executeRegexp = regexp.MustCompile( - `(?si)[:+](become|execute(?:-multi|-silent)?|reload(?:-sync)?|preview|(?:change|&?transform)-(?:query|prompt|(?:border|list|preview|input|header|footer)-label|header|footer|search|nth|pointer|ghost)|&?transform|change-(?:preview-window|preview|multi)|(?:re|un|toggle-)bind|pos|put|print|search)`) + `(?si)[:+](become|execute(?:-multi|-silent)?|reload(?:-sync)?|preview|(?:change|transform|bg-transform)-(?:query|prompt|(?:border|list|preview|input|header|footer)-label|header|footer|search|nth|pointer|ghost)|transform|bg-transform|change-(?:preview-window|preview|multi)|(?:re|un|toggle-)bind|pos|put|print|search)`) splitRegexp = regexp.MustCompile("[,:]+") actionNameRegexp = regexp.MustCompile("(?i)^&?[a-z-]+") } @@ -1892,35 +1892,35 @@ func isExecuteAction(str string) actionType { return actTransformQuery case "transform-search": return actTransformSearch - case "&transform": + case "bg-transform": return actAsyncTransform - case "&transform-list-label": + case "bg-transform-list-label": return actAsyncTransformListLabel - case "&transform-border-label": + case "bg-transform-border-label": return actAsyncTransformBorderLabel - case "&transform-preview-label": + case "bg-transform-preview-label": return actAsyncTransformPreviewLabel - case "&transform-input-label": + case "bg-transform-input-label": return actAsyncTransformInputLabel - case "&transform-header-label": + case "bg-transform-header-label": return actAsyncTransformHeaderLabel - case "&transform-footer-label": + case "bg-transform-footer-label": return actAsyncTransformFooterLabel - case "&transform-footer": + case "bg-transform-footer": return actAsyncTransformFooter - case "&transform-header": + case "bg-transform-header": return actAsyncTransformHeader - case "&transform-ghost": + case "bg-transform-ghost": return actAsyncTransformGhost - case "&transform-nth": + case "bg-transform-nth": return actAsyncTransformNth - case "&transform-pointer": + case "bg-transform-pointer": return actAsyncTransformPointer - case "&transform-prompt": + case "bg-transform-prompt": return actAsyncTransformPrompt - case "&transform-query": + case "bg-transform-query": return actAsyncTransformQuery - case "&transform-search": + case "bg-transform-search": return actAsyncTransformSearch case "search": return actSearch diff --git a/test/test_core.rb b/test/test_core.rb index d195b92c..f714e1c3 100644 --- a/test/test_core.rb +++ b/test/test_core.rb @@ -1944,16 +1944,16 @@ class TestCore < TestInteractive time = Time.now tmux.send_keys %( seq 100 | #{FZF} --style full --border --preview : \ - --bind 'focus:&transform-header(sleep 0.5; echo th.)' \ - --bind 'focus:+&transform-footer(sleep 0.5; echo tf.)' \ - --bind 'focus:+&transform-border-label(sleep 0.5; echo tbl.)' \ - --bind "focus:+&transform-preview-label(sleep 0.5; echo tpl.)" \ - --bind 'focus:+&transform-input-label(sleep 0.5; echo til.)' \ - --bind 'focus:+&transform-list-label(sleep 0.5; echo tll.)' \ - --bind 'focus:+&transform-header-label(sleep 0.5; echo thl.)' \ - --bind 'focus:+&transform-footer-label(sleep 0.5; echo tfl.)' \ - --bind 'focus:+&transform-prompt(sleep 0.5; echo tp.)' \ - --bind 'focus:+&transform-ghost(sleep 0.5; echo tg.)' + --bind 'focus:bg-transform-header(sleep 0.5; echo th.)' \ + --bind 'focus:+bg-transform-footer(sleep 0.5; echo tf.)' \ + --bind 'focus:+bg-transform-border-label(sleep 0.5; echo tbl.)' \ + --bind "focus:+bg-transform-preview-label(sleep 0.5; echo tpl.)" \ + --bind 'focus:+bg-transform-input-label(sleep 0.5; echo til.)' \ + --bind 'focus:+bg-transform-list-label(sleep 0.5; echo tll.)' \ + --bind 'focus:+bg-transform-header-label(sleep 0.5; echo thl.)' \ + --bind 'focus:+bg-transform-footer-label(sleep 0.5; echo tfl.)' \ + --bind 'focus:+bg-transform-prompt(sleep 0.5; echo tp.)' \ + --bind 'focus:+bg-transform-ghost(sleep 0.5; echo tg.)' ).strip, :Enter tmux.until do |lines| assert lines.any_include?('100/100')