mirror of
https://github.com/junegunn/fzf.git
synced 2025-05-19 12:50:22 -07:00
Enable preview if 'transform' action is bound to a key
This commit is contained in:
parent
d210660ce8
commit
412040f77e
@ -587,10 +587,14 @@ func trimQuery(query string) []rune {
|
|||||||
return []rune(strings.Replace(query, "\t", " ", -1))
|
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 _, actions := range opts.Keymap {
|
||||||
for _, action := range actions {
|
for _, action := range actions {
|
||||||
if action.t == actPreview || action.t == actChangePreview {
|
switch action.t {
|
||||||
|
case actPreview, actChangePreview, actTransform:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -629,8 +633,11 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|||||||
delay = initialDelay
|
delay = initialDelay
|
||||||
}
|
}
|
||||||
var previewBox *util.EventBox
|
var previewBox *util.EventBox
|
||||||
// We need to start previewer if HTTP server is enabled even when --preview option is not specified
|
// We need to start the previewer even when --preview option is not specified
|
||||||
if len(opts.Preview.command) > 0 || hasPreviewAction(opts) || opts.ListenAddr != nil {
|
// * 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()
|
previewBox = util.NewEventBox()
|
||||||
}
|
}
|
||||||
var renderer tui.Renderer
|
var renderer tui.Renderer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user