diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2020-10-09 21:56:16 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2020-10-09 21:56:16 +0900 |
commit | 865144850da99307fa3345f78de792ddbb1bd260 (patch) | |
tree | c24d5fdab64a85d62f6ba154aba440d007bcdd0d /src | |
parent | d9752a4c21ba8a98e26dcf2199f22581d3946dfa (diff) |
Add nowrap, nocycle, nohidden for --preview-window
Close #2203
Diffstat (limited to 'src')
-rw-r--r-- | src/options.go | 15 | ||||
-rw-r--r-- | src/options_test.go | 4 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/options.go b/src/options.go index c7354b35..51e5001c 100644 --- a/src/options.go +++ b/src/options.go @@ -80,9 +80,10 @@ const usage = `usage: fzf [options] Preview --preview=COMMAND Command to preview highlighted line ({}) --preview-window=OPT Preview window layout (default: right:50%) - [up|down|left|right][:SIZE[%]][:wrap][:cycle][:hidden] - [:+SCROLL[-OFFSET]] + [up|down|left|right][:SIZE[%]] + [:[no]wrap][:[no]cycle][:[no]hidden] [:rounded|sharp|noborder] + [:+SCROLL[-OFFSET]] Scripting -q, --query=STR Start the finder with the given query @@ -994,10 +995,6 @@ func parseInfoStyle(str string) infoStyle { } func parsePreviewWindow(opts *previewOpts, input string) { - // We should reset flags that are not style-related. - opts.hidden = false - opts.scroll = "" - tokens := strings.Split(input, ":") sizeRegex := regexp.MustCompile("^[0-9]+%?$") offsetRegex := regexp.MustCompile("^\\+([0-9]+|{-?[0-9]+})(-[0-9]+|-/[1-9][0-9]*)?$") @@ -1006,10 +1003,16 @@ func parsePreviewWindow(opts *previewOpts, input string) { case "": case "hidden": opts.hidden = true + case "nohidden": + opts.hidden = false case "wrap": opts.wrap = true + case "nowrap": + opts.wrap = false case "cycle": opts.cycle = true + case "nocycle": + opts.cycle = false case "up", "top": opts.position = posUp case "down", "bottom": diff --git a/src/options_test.go b/src/options_test.go index 38873738..aae8eedc 100644 --- a/src/options_test.go +++ b/src/options_test.go @@ -399,11 +399,11 @@ func TestPreviewOpts(t *testing.T) { } opts = optsFor("--preview-window=up:15:wrap:hidden:+{1}-/2", "--preview-window=down", "--preview-window=cycle") if !(opts.Preview.command == "" && - opts.Preview.hidden == false && + opts.Preview.hidden == true && opts.Preview.wrap == true && opts.Preview.cycle == true && opts.Preview.position == posDown && - opts.Preview.scroll == "" && + opts.Preview.scroll == "{1}-/2" && opts.Preview.size.percent == false && opts.Preview.size.size == 15) { t.Error(opts.Preview.size.size) |