diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2023-12-31 20:55:24 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-12-31 20:56:33 +0900 |
commit | 412040f77ecd24926f8b0ecbc12ec1b7d3be6b6d (patch) | |
tree | e49b820c314155a453199898ea344be7ab7e7dc1 | |
parent | d210660ce8302fa54836f8682db213c1fac877ba (diff) |
Enable preview if 'transform' action is bound to a key
-rw-r--r-- | src/terminal.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/terminal.go b/src/terminal.go index 0e378584..152475f8 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -587,10 +587,14 @@ func trimQuery(query string) []rune { return []rune(strings.Replace(query, "\t", " ", -1)) } -func hasPreviewAction(opts *Options) bool { +func mayTriggerPreview(opts *Options) bool { + if opts.ListenAddr != nil { + return true + } for _, actions := range opts.Keymap { for _, action := range actions { - if action.t == actPreview || action.t == actChangePreview { + switch action.t { + case actPreview, actChangePreview, actTransform: return true } } @@ -629,8 +633,11 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal { delay = initialDelay } var previewBox *util.EventBox - // We need to start previewer if HTTP server is enabled even when --preview option is not specified - if len(opts.Preview.command) > 0 || hasPreviewAction(opts) || opts.ListenAddr != nil { + // We need to start the previewer even when --preview option is not specified + // * if HTTP server is enabled + // * if 'preview' or 'change-preview' action is bound to a key + // * if 'transform' action is bound to a key + if len(opts.Preview.command) > 0 || mayTriggerPreview(opts) { previewBox = util.NewEventBox() } var renderer tui.Renderer |