summaryrefslogtreecommitdiffstats
path: root/src
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 /src
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%
Diffstat (limited to 'src')
-rw-r--r--src/options.go15
-rw-r--r--src/options_test.go4
2 files changed, 10 insertions, 9 deletions
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 &&