Add --preview-window follow option

This commit is contained in:
Junegunn Choi
2020-12-05 21:16:35 +09:00
parent cbfee31593
commit 2ec382ae0e
5 changed files with 78 additions and 36 deletions

View File

@@ -83,7 +83,7 @@ const usage = `usage: fzf [options]
--preview=COMMAND Command to preview highlighted line ({})
--preview-window=OPT Preview window layout (default: right:50%)
[up|down|left|right][:SIZE[%]]
[:[no]wrap][:[no]cycle][:[no]hidden]
[:[no]wrap][:[no]cycle][:[no]follow][:[no]hidden]
[:rounded|sharp|noborder]
[:+SCROLL[-OFFSET]]
[:default]
@@ -169,6 +169,7 @@ type previewOpts struct {
hidden bool
wrap bool
cycle bool
follow bool
border tui.BorderShape
}
@@ -231,7 +232,7 @@ type Options struct {
}
func defaultPreviewOpts(command string) previewOpts {
return previewOpts{command, posRight, sizeSpec{50, true}, "", false, false, false, tui.BorderRounded}
return previewOpts{command, posRight, sizeSpec{50, true}, "", false, false, false, false, tui.BorderRounded}
}
func defaultOptions() *Options {
@@ -1081,6 +1082,10 @@ func parsePreviewWindow(opts *previewOpts, input string) {
opts.border = tui.BorderSharp
case "noborder":
opts.border = tui.BorderNone
case "follow":
opts.follow = true
case "nofollow":
opts.follow = false
default:
if sizeRegex.MatchString(token) {
opts.size = parseSize(token, 99, "window size")