Skip to content
Myr

Add --preview-window=default for resetting the options

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 246b9f3 · Browse files · 4 files+20 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+20 added−3 removed

  • other:+20 added−3 removed

4 files+20 added−3 removed

modified:man/man1/fzf.1+3 added-1 removed
379 unmodified lines
380Preview window will be updated even when there is no match for the current381query if any of the placeholder expressions evaluates to a non-empty string.382.RE383.TP384.BI "--preview-window=" "[POSITION][:SIZE[%]][:rounded|sharp|noborder][:[no]wrap][:[no]cycle][:[no]hidden][:+SCROLL[-OFFSET]]"384.BI "--preview-window=" "[POSITION][:SIZE[%]][:rounded|sharp|noborder][:[no]wrap][:[no]cycle][:[no]hidden][:+SCROLL[-OFFSET]][:default]"385386.RS387.B POSITION: (default: right)388 \fBup
21 unmodified lines
410for adjusting the base offset so that you can see the text above it. It should411be given as a numeric integer (\fB-INTEGER\fR), or as a denominator form412(\fB-/INTEGER\fR) for specifying a fraction of the preview window height.413414\fBdefault\fR resets all options previously set to the default.415416.RS417e.g.418 \fB# Non-default scroll window positions and sizes419 fzf --preview="head {}" --preview-window=up:30%
433 unmodified lines
modified:src/options_test.go+7 added
415 unmodified lines
416 opts.Preview.size.percent == false &&417 opts.Preview.size.size == 15) {418 t.Error(opts.Preview)419 }420 opts = optsFor("--preview=foo", "--preview-window=up", "--preview-window=default:70%")421 if !(opts.Preview.command == "foo" &&422 opts.Preview.position == posRight &&423 opts.Preview.size.percent == true &&424 opts.Preview.size.size == 70) {425 t.Error(opts.Preview)426 }427}428429func TestAdditiveExpect(t *testing.T) {430 opts := optsFor("--expect=a", "--expect", "b", "--expect=c")
30 unmodified lines
modified:src/options.go+9 added-2 removed
82 unmodified lines
83 [up|down|left|right][:SIZE[%]]84 [:[no]wrap][:[no]cycle][:[no]hidden]85 [:rounded|sharp|noborder]86 [:+SCROLL[-OFFSET]]87 [:default]8889 Scripting90 -q, --query=STR Start the finder with the given query91 -1, --select-1 Automatically select the only match
134 unmodified lines
226 ClearOnExit bool227 Version bool228}229230func defaultPreviewOpts(command string) previewOpts {231 return previewOpts{command, posRight, sizeSpec{50, true}, "", false, false, false, tui.BorderRounded}232}233234func defaultOptions() *Options {235 return &Options{236 Fuzzy: true,237 FuzzyAlgo: algo.FuzzyMatchV2,
31 unmodified lines
269 Filter: nil,270 ToggleSort: false,271 Expect: make(map[int]string),272 Keymap: make(map[int][]action),268 Preview: previewOpts{"", posRight, sizeSpec{50, true}, "", false, false, false, tui.BorderRounded},273 Preview: defaultPreviewOpts(""),274 PrintQuery: false,275 ReadZero: false,276 Printer: func(str string) { fmt.Println(str) },277 PrintSep: "\n",
727 unmodified lines
1005 offsetRegex := regexp.MustCompile("^\\+([0-9]+|{-?[0-9]+})(-[0-9]+|-/[1-9][0-9]*)?$")1006 for _, token := range tokens {1007 switch token {1008 case "":1009 case "default":1010 *opts = defaultPreviewOpts(opts.command)1011 case "hidden":1012 opts.hidden = true1013 case "nohidden":1014 opts.hidden = false
269 unmodified lines
1284 case "--no-preview":1285 opts.Preview.command = ""1286 case "--preview-window":1287 parsePreviewWindow(&opts.Preview,1281 nextString(allArgs, &i, "preview window layout required: [up|down|left|right][:SIZE[%]][:rounded|sharp|noborder][:wrap][:cycle][:hidden][:+SCROLL[-OFFSET]]"))1288 nextString(allArgs, &i, "preview window layout required: [up|down|left|right][:SIZE[%]][:rounded|sharp|noborder][:wrap][:cycle][:hidden][:+SCROLL[-OFFSET]][:default]"))1289 case "--height":1290 opts.Height = parseHeight(nextString(allArgs, &i, "height required: HEIGHT[%]"))1291 case "--min-height":1292 opts.MinHeight = nextInt(allArgs, &i, "height required: HEIGHT")
206 unmodified lines
modified:CHANGELOG.md+1 added
5 unmodified lines
6- Added `--preview-window` options for disabling flags7 - `nocycle`8 - `nohidden`9 - `nowrap`10 - `default`11120.23.013------14- Support preview scroll offset relative to window height
931 unmodified lines