m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 00:03:39 -05:00

Add 'show-preview' and 'hide-preview'

For cases where 'toggle-preview' is not enough
This commit is contained in:
Junegunn Choi
2023-01-31 17:33:53 +09:00
parent 3ee00f8bc2
commit aa2b9ec476
5 changed files with 62 additions and 3 deletions

View File

@@ -1111,6 +1111,10 @@ func parseActionList(masked string, original string, prevActions []*action, putA
appendAction(actPrevSelected)
case "next-selected":
appendAction(actNextSelected)
case "show-preview":
appendAction(actShowPreview)
case "hide-preview":
appendAction(actHidePreview)
case "toggle-preview":
appendAction(actTogglePreview)
case "toggle-preview-wrap":

View File

@@ -350,6 +350,8 @@ const (
actRefreshPreview
actReplaceQuery
actToggleSort
actShowPreview
actHidePreview
actTogglePreview
actTogglePreviewWrap
actTransformBorderLabel
@@ -2866,8 +2868,17 @@ func (t *Terminal) Loop() {
case actInvalid:
t.mutex.Unlock()
return false
case actTogglePreview:
if t.hasPreviewWindow() || len(t.previewOpts.command) > 0 {
case actTogglePreview, actShowPreview, actHidePreview:
var act bool
switch a.t {
case actShowPreview:
act = !t.hasPreviewWindow() && len(t.previewOpts.command) > 0
case actHidePreview:
act = t.hasPreviewWindow()
case actTogglePreview:
act = t.hasPreviewWindow() || len(t.previewOpts.command) > 0
}
if act {
t.activePreviewOpts.Toggle()
updatePreviewWindow(false)
if t.isPreviewEnabled() {