Skip to content
Myr

Add nowrap, nocycle, nohidden for --preview-window

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

Close #2203

authored by Junegunn Choi · committed by Junegunn Choi · parent d9752a4 · Browse files · 4 files+16 added−24 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+16 added−24 removed

  • other:+16 added−24 removed

4 files+16 added−24 removed

modified:man/man1/fzf.1+1 added-13 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][:wrap][:cycle][:hidden][:+SCROLL[-OFFSET]]"384.BI "--preview-window=" "[POSITION][:SIZE[%]][:rounded|sharp|noborder][:[no]wrap][:[no]cycle][:[no]hidden][:+SCROLL[-OFFSET]]"385386.RS387.B POSITION: (default: right)388 \fBup
40 unmodified lines
429 --preview-window +{2}-/2\fR430431.RE432433You can write style-related flags across multiple \fB--preview-window\fR434options. But flags that are not style-related such as \fBhidden\fR and scroll435offset are only allowed in the last \fB--preview-window\fR.436437.RS438e.g.439 export FZF_DEFAULT_OPTS='--preview-window sharp:cycle'440441 # sharp + cycle + up + 50%442 fzf --preview-window 'up' --preview-window '50%' --preview 'bat {}'443.RE444433.SS Scripting434.TP435.BI "-q, --query=" "STR"436Start the finder with the given query
414 unmodified lines
modified:src/options_test.go+2 added-2 removed
397 unmodified lines
398 t.Error(opts.Preview)399 }400 opts = optsFor("--preview-window=up:15:wrap:hidden:+{1}-/2", "--preview-window=down", "--preview-window=cycle")401 if !(opts.Preview.command == "" &&402 opts.Preview.hidden == false &&402 opts.Preview.hidden == true &&403 opts.Preview.wrap == true &&404 opts.Preview.cycle == true &&405 opts.Preview.position == posDown &&406 opts.Preview.scroll == "" &&406 opts.Preview.scroll == "{1}-/2" &&407 opts.Preview.size.percent == false &&408 opts.Preview.size.size == 15) {409 t.Error(opts.Preview.size.size)410 }
43 unmodified lines
modified:src/options.go+9 added-6 removed
78 unmodified lines
7980 Preview81 --preview=COMMAND Command to preview highlighted line ({})82 --preview-window=OPT Preview window layout (default: right:50%)83 [up|down|left|right][:SIZE[%]][:wrap][:cycle][:hidden]84 [:+SCROLL[-OFFSET]]83 [up|down|left|right][:SIZE[%]]84 [:[no]wrap][:[no]cycle][:[no]hidden]85 [:rounded|sharp|noborder]86 [:+SCROLL[-OFFSET]]8788 Scripting89 -q, --query=STR Start the finder with the given query90 -1, --select-1 Automatically select the only match
903 unmodified lines
994 return infoDefault995}996997func parsePreviewWindow(opts *previewOpts, input string) {997 // We should reset flags that are not style-related.998 opts.hidden = false999 opts.scroll = ""1000998 tokens := strings.Split(input, ":")999 sizeRegex := regexp.MustCompile("^[0-9]+%?$")1000 offsetRegex := regexp.MustCompile("^\\+([0-9]+|{-?[0-9]+})(-[0-9]+|-/[1-9][0-9]*)?$")1001 for _, token := range tokens {1002 switch token {1003 case "":1004 case "hidden":1005 opts.hidden = true1006 case "nohidden":1007 opts.hidden = false1008 case "wrap":1009 opts.wrap = true1010 case "nowrap":1011 opts.wrap = false1012 case "cycle":1013 opts.cycle = true1014 case "nocycle":1015 opts.cycle = false1016 case "up", "top":1017 opts.position = posUp1018 case "down", "bottom":1019 opts.position = posDown
472 unmodified lines
modified:CHANGELOG.md+4 added-3 removed
1 unmodified line
2=========340.23.15------6- Reset `hidden` flag and scroll offset of `--preview-window` if another7 `--preview-window` is found. We should only keep style-related flags across8 multiple `--preview-window` options.6- Added `--preview-window` options for disabling flags7 - `nocycle`8 - `nohidden`9 - `nowrap`10110.23.012------13- Support preview scroll offset relative to window height
931 unmodified lines