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
Provenance
- Commit
8651448- Tree
c24d5fd- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
d9752a4
4 files changed+16 added−24 removed
modified:man/man1/fzf.1+1 added-13 removed
379 unmodified lines380 Preview window will be updated even when there is no match for the current381 query 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]]"385 386 .RS387 .B POSITION: (default: right)388 \fBup40 unmodified lines429 --preview-window +{2}-/2\fR430 431 .RE432 433-You can write style-related flags across multiple \fB--preview-window\fR434-options. But flags that are not style-related such as \fBhidden\fR and scroll435-offset are only allowed in the last \fB--preview-window\fR.436-437-.RS438-e.g.439- export FZF_DEFAULT_OPTS='--preview-window sharp:cycle'440-441- # sharp + cycle + up + 50%442- fzf --preview-window 'up' --preview-window '50%' --preview 'bat {}'443-.RE444-433 .SS Scripting434 .TP435 .BI "-q, --query=" "STR"436 Start the finder with the given query414 unmodified linesmodified:src/options_test.go+2 added-2 removed
397 unmodified lines398 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 linesmodified:src/options.go+9 added-6 removed
78 unmodified lines79 80 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]]87 88 Scripting89 -q, --query=STR Start the finder with the given query90 -1, --select-1 Automatically select the only match903 unmodified lines994 return infoDefault995 }996 997 func parsePreviewWindow(opts *previewOpts, input string) {997- // We should reset flags that are not style-related.998- opts.hidden = false999- opts.scroll = ""1000-998 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 = posDown472 unmodified linesmodified:CHANGELOG.md+4 added-3 removed
1 unmodified line2 =========3 4 0.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`10 11 0.23.012 ------13 - Support preview scroll offset relative to window height931 unmodified lines