mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-06-03 07:50:49 +00:00
parent
dba14d2630
commit
d9752a4c21
|
@ -1,6 +1,12 @@
|
||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
0.23.1
|
||||||
|
------
|
||||||
|
- Reset `hidden` flag and scroll offset of `--preview-window` if another
|
||||||
|
`--preview-window` is found. We should only keep style-related flags across
|
||||||
|
multiple `--preview-window` options.
|
||||||
|
|
||||||
0.23.0
|
0.23.0
|
||||||
------
|
------
|
||||||
- Support preview scroll offset relative to window height
|
- Support preview scroll offset relative to window height
|
||||||
|
|
|
@ -381,11 +381,21 @@ Preview window will be updated even when there is no match for the current
|
||||||
query if any of the placeholder expressions evaluates to a non-empty string.
|
query if any of the placeholder expressions evaluates to a non-empty string.
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.BI "--preview-window=" "[POSITION][:SIZE[%]][:rounded|sharp|noborder][:wrap][:hidden][:+SCROLL[-OFFSET]]"
|
.BI "--preview-window=" "[POSITION][:SIZE[%]][:rounded|sharp|noborder][:wrap][:cycle][:hidden][:+SCROLL[-OFFSET]]"
|
||||||
Determines the layout of the preview window. If the argument contains
|
|
||||||
|
.RS
|
||||||
|
.B POSITION: (default: right)
|
||||||
|
\fBup
|
||||||
|
\fBdown
|
||||||
|
\fBleft
|
||||||
|
\fBright
|
||||||
|
.RE
|
||||||
|
|
||||||
|
\fRDetermines the layout of the preview window. If the argument contains
|
||||||
\fB:hidden\fR, the preview window will be hidden by default until
|
\fB:hidden\fR, the preview window will be hidden by default until
|
||||||
\fBtoggle-preview\fR action is triggered. Long lines are truncated by default.
|
\fBtoggle-preview\fR action is triggered. Long lines are truncated by default.
|
||||||
Line wrap can be enabled with \fB:wrap\fR flag.
|
Line wrap can be enabled with \fB:wrap\fR flag. Cyclic scrolling is enabled
|
||||||
|
with \fB:cycle\fR flag.
|
||||||
|
|
||||||
If size is given as 0, preview window will not be visible, but fzf will still
|
If size is given as 0, preview window will not be visible, but fzf will still
|
||||||
execute the command in the background.
|
execute the command in the background.
|
||||||
|
@ -401,14 +411,6 @@ for adjusting the base offset so that you can see the text above it. It should
|
||||||
be given as a numeric integer (\fB-INTEGER\fR), or as a denominator form
|
be given as a numeric integer (\fB-INTEGER\fR), or as a denominator form
|
||||||
(\fB-/INTEGER\fR) for specifying a fraction of the preview window height.
|
(\fB-/INTEGER\fR) for specifying a fraction of the preview window height.
|
||||||
|
|
||||||
.RS
|
|
||||||
.B POSITION: (default: right)
|
|
||||||
\fBup
|
|
||||||
\fBdown
|
|
||||||
\fBleft
|
|
||||||
\fBright
|
|
||||||
.RE
|
|
||||||
|
|
||||||
.RS
|
.RS
|
||||||
e.g.
|
e.g.
|
||||||
\fB# Non-default scroll window positions and sizes
|
\fB# Non-default scroll window positions and sizes
|
||||||
|
@ -427,6 +429,19 @@ e.g.
|
||||||
--preview-window +{2}-/2\fR
|
--preview-window +{2}-/2\fR
|
||||||
|
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
|
You can write style-related flags across multiple \fB--preview-window\fR
|
||||||
|
options. But flags that are not style-related such as \fBhidden\fR and scroll
|
||||||
|
offset are only allowed in the last \fB--preview-window\fR.
|
||||||
|
|
||||||
|
.RS
|
||||||
|
e.g.
|
||||||
|
export FZF_DEFAULT_OPTS='--preview-window sharp:cycle'
|
||||||
|
|
||||||
|
# sharp + cycle + up + 50%
|
||||||
|
fzf --preview-window 'up' --preview-window '50%' --preview 'bat {}'
|
||||||
|
.RE
|
||||||
|
|
||||||
.SS Scripting
|
.SS Scripting
|
||||||
.TP
|
.TP
|
||||||
.BI "-q, --query=" "STR"
|
.BI "-q, --query=" "STR"
|
||||||
|
|
|
@ -994,6 +994,10 @@ func parseInfoStyle(str string) infoStyle {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parsePreviewWindow(opts *previewOpts, input string) {
|
func parsePreviewWindow(opts *previewOpts, input string) {
|
||||||
|
// We should reset flags that are not style-related.
|
||||||
|
opts.hidden = false
|
||||||
|
opts.scroll = ""
|
||||||
|
|
||||||
tokens := strings.Split(input, ":")
|
tokens := strings.Split(input, ":")
|
||||||
sizeRegex := regexp.MustCompile("^[0-9]+%?$")
|
sizeRegex := regexp.MustCompile("^[0-9]+%?$")
|
||||||
offsetRegex := regexp.MustCompile("^\\+([0-9]+|{-?[0-9]+})(-[0-9]+|-/[1-9][0-9]*)?$")
|
offsetRegex := regexp.MustCompile("^\\+([0-9]+|{-?[0-9]+})(-[0-9]+|-/[1-9][0-9]*)?$")
|
||||||
|
|
|
@ -387,21 +387,23 @@ func TestPreviewOpts(t *testing.T) {
|
||||||
opts.Preview.size.size == 50) {
|
opts.Preview.size.size == 50) {
|
||||||
t.Error()
|
t.Error()
|
||||||
}
|
}
|
||||||
opts = optsFor("--preview", "cat {}", "--preview-window=left:15:hidden:wrap")
|
opts = optsFor("--preview", "cat {}", "--preview-window=left:15:hidden:wrap:+{1}-/2")
|
||||||
if !(opts.Preview.command == "cat {}" &&
|
if !(opts.Preview.command == "cat {}" &&
|
||||||
opts.Preview.hidden == true &&
|
opts.Preview.hidden == true &&
|
||||||
opts.Preview.wrap == true &&
|
opts.Preview.wrap == true &&
|
||||||
opts.Preview.position == posLeft &&
|
opts.Preview.position == posLeft &&
|
||||||
|
opts.Preview.scroll == "{1}-/2" &&
|
||||||
opts.Preview.size.percent == false &&
|
opts.Preview.size.percent == false &&
|
||||||
opts.Preview.size.size == 15) {
|
opts.Preview.size.size == 15) {
|
||||||
t.Error(opts.Preview)
|
t.Error(opts.Preview)
|
||||||
}
|
}
|
||||||
opts = optsFor("--preview-window=up:15:wrap:hidden", "--preview-window=down", "--preview-window=cycle")
|
opts = optsFor("--preview-window=up:15:wrap:hidden:+{1}-/2", "--preview-window=down", "--preview-window=cycle")
|
||||||
if !(opts.Preview.command == "" &&
|
if !(opts.Preview.command == "" &&
|
||||||
opts.Preview.hidden == true &&
|
opts.Preview.hidden == false &&
|
||||||
opts.Preview.wrap == true &&
|
opts.Preview.wrap == true &&
|
||||||
opts.Preview.cycle == true &&
|
opts.Preview.cycle == true &&
|
||||||
opts.Preview.position == posDown &&
|
opts.Preview.position == posDown &&
|
||||||
|
opts.Preview.scroll == "" &&
|
||||||
opts.Preview.size.percent == false &&
|
opts.Preview.size.percent == false &&
|
||||||
opts.Preview.size.size == 15) {
|
opts.Preview.size.size == 15) {
|
||||||
t.Error(opts.Preview.size.size)
|
t.Error(opts.Preview.size.size)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user