summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2021-04-06 20:10:55 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2021-04-06 20:10:55 +0900
commitda1f64567064de34bc26fd3b6390fb80f0054319 (patch)
tree9af64ea44389d0861ce2c60b8852c1bac7b95d78
parent3a2015ee26a75f776ab097e293aec57abd1aa833 (diff)
Change --preview-window delimiter from : to , for consistency
Delimiter : was chosen when --preview-option only supported position and size attributes. e.g. up:50%
-rw-r--r--man/man1/fzf.18
-rw-r--r--src/options.go15
-rw-r--r--src/options_test.go4
3 files changed, 14 insertions, 13 deletions
diff --git a/man/man1/fzf.1 b/man/man1/fzf.1
index d5b26c9f..ae16a75a 100644
--- a/man/man1/fzf.1
+++ b/man/man1/fzf.1
@@ -444,7 +444,7 @@ e.g.
done'\fR
.RE
.TP
-.BI "--preview-window=" "[POSITION][:SIZE[%]][:border-BORDER_OPT][:[no]wrap][:[no]follow][:[no]cycle][:[no]hidden][:+SCROLL[OFFSETS][/DENOM]][:~HEADER_LINES][:default]"
+.BI "--preview-window=" "[POSITION][,SIZE[%]][,border-BORDER_OPT][,[no]wrap][,[no]follow][,[no]cycle][,[no]hidden][,+SCROLL[OFFSETS][/DENOM]][,~HEADER_LINES][,default]"
.RS
.B POSITION: (default: right)
@@ -501,8 +501,8 @@ are always visible.
.RS
e.g.
\fB# Non-default scroll window positions and sizes
- fzf --preview="head {}" --preview-window=up:30%
- fzf --preview="file {}" --preview-window=down:1
+ fzf --preview="head {}" --preview-window=up,30%
+ fzf --preview="file {}" --preview-window=down,1
# Initial scroll offset is set to the line number of each line of
# git grep output *minus* 5 lines (-5)
@@ -520,7 +520,7 @@ e.g.
git grep --line-number '' |
fzf --delimiter : \\
--preview 'bat --style=full --color=always --highlight-line {2} {1}' \\
- --preview-window '~3:+{2}+3/2'
+ --preview-window '~3,+{2}+3/2'
# Display top 3 lines as the fixed header
fzf --preview 'bat --style=full --color=always {}' --preview-window '~3'\fR
diff --git a/src/options.go b/src/options.go
index bb134fa0..a136b859 100644
--- a/src/options.go
+++ b/src/options.go
@@ -81,11 +81,11 @@ 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[%]]
- [:[no]wrap][:[no]cycle][:[no]follow][:[no]hidden]
- [:border-BORDER_OPT]
- [:+SCROLL[OFFSETS][/DENOM]][:~HEADER_LINES]
- [:default]
+ [up|down|left|right][,SIZE[%]]
+ [,[no]wrap][,[no]cycle][,[no]follow][,[no]hidden]
+ [,border-BORDER_OPT]
+ [,+SCROLL[OFFSETS][/DENOM]][,~HEADER_LINES]
+ [,default]
Scripting
-q, --query=STR Start the finder with the given query
@@ -1078,10 +1078,11 @@ func parseInfoStyle(str string) infoStyle {
}
func parsePreviewWindow(opts *previewOpts, input string) {
- tokens := strings.Split(input, ":")
+ delimRegex := regexp.MustCompile("[:,]") // : for backward compatibility
sizeRegex := regexp.MustCompile("^[0-9]+%?$")
offsetRegex := regexp.MustCompile(`^(\+{-?[0-9]+})?([+-][0-9]+)*(-?/[1-9][0-9]*)?$`)
headerRegex := regexp.MustCompile("^~(0|[1-9][0-9]*)$")
+ tokens := delimRegex.Split(input, -1)
for _, token := range tokens {
switch token {
case "":
@@ -1382,7 +1383,7 @@ func parseOptions(opts *Options, allArgs []string) {
opts.Preview.command = ""
case "--preview-window":
parsePreviewWindow(&opts.Preview,
- nextString(allArgs, &i, "preview window layout required: [up|down|left|right][:SIZE[%]][:rounded|sharp|noborder][:wrap][:cycle][:hidden][:+SCROLL[OFFSETS][/DENOM]][:~HEADER_LINES][:default]"))
+ nextString(allArgs, &i, "preview window layout required: [up|down|left|right][,SIZE[%]][,border-BORDER_OPT][,wrap][,cycle][,hidden][,+SCROLL[OFFSETS][/DENOM]][,~HEADER_LINES][,default]"))
case "--height":
opts.Height = parseHeight(nextString(allArgs, &i, "height required: HEIGHT[%]"))
case "--min-height":
diff --git a/src/options_test.go b/src/options_test.go
index ce135413..bb946235 100644
--- a/src/options_test.go
+++ b/src/options_test.go
@@ -384,7 +384,7 @@ func TestPreviewOpts(t *testing.T) {
opts.Preview.size.size == 50) {
t.Error()
}
- opts = optsFor("--preview", "cat {}", "--preview-window=left:15:hidden:wrap:+{1}-/2")
+ opts = optsFor("--preview", "cat {}", "--preview-window=left:15,hidden,wrap:+{1}-/2")
if !(opts.Preview.command == "cat {}" &&
opts.Preview.hidden == true &&
opts.Preview.wrap == true &&
@@ -394,7 +394,7 @@ func TestPreviewOpts(t *testing.T) {
opts.Preview.size.size == 15) {
t.Error(opts.Preview)
}
- opts = optsFor("--preview-window=up:15:wrap:hidden:+{1}+3-1-2/2", "--preview-window=down", "--preview-window=cycle")
+ opts = optsFor("--preview-window=up,15,wrap,hidden,+{1}+3-1-2/2", "--preview-window=down", "--preview-window=cycle")
if !(opts.Preview.command == "" &&
opts.Preview.hidden == true &&
opts.Preview.wrap == true &&