From 7a7cfcacbe013f6ce179fb25a4b81c940b687af3 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 21 Jul 2022 22:24:11 +0900 Subject: [PATCH] Lift unicode.IsGraphic constraint for pointer, marker, and ellipsis Use at your own risk. Close #2709 Close #2055 --- CHANGELOG.md | 3 +++ src/options.go | 16 ---------------- src/options_test.go | 2 -- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c9b82..dc1e3eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ CHANGELOG fzf --preview 'cat {}' --preview-window '<50(hidden)' ``` - Use SGR mouse mode to support larger terminals +- You can now use characters that does not satisfy `unicode.IsGraphic` constraint + for `--marker`, `--pointer`, and `--ellipsis`. Allows Nerd Fonts and stuff. + Use at your own risk. - Bug fixes and improvements - Shell extension - `kill` completion now requires trigger sequence (`**`) for consistency diff --git a/src/options.go b/src/options.go index cb1b7ef..7e626f6 100644 --- a/src/options.go +++ b/src/options.go @@ -1307,7 +1307,6 @@ func parseOptions(opts *Options, allArgs []string) { validateJumpLabels := false validatePointer := false validateMarker := false - validateEllipsis := false for i := 0; i < len(allArgs); i++ { arg := allArgs[i] switch arg { @@ -1495,7 +1494,6 @@ func parseOptions(opts *Options, allArgs []string) { opts.HeaderFirst = false case "--ellipsis": opts.Ellipsis = nextString(allArgs, &i, "ellipsis string required") - validateEllipsis = true case "--preview": opts.Preview.command = nextString(allArgs, &i, "preview command required") case "--no-preview": @@ -1595,7 +1593,6 @@ func parseOptions(opts *Options, allArgs []string) { opts.HeaderLines = atoi(value) } else if match, value := optString(arg, "--ellipsis="); match { opts.Ellipsis = value - validateEllipsis = true } else if match, value := optString(arg, "--preview="); match { opts.Preview.command = value } else if match, value := optString(arg, "--preview-window="); match { @@ -1658,25 +1655,12 @@ func parseOptions(opts *Options, allArgs []string) { errorExit(err.Error()) } } - - if validateEllipsis { - for _, r := range opts.Ellipsis { - if !unicode.IsGraphic(r) { - errorExit("invalid character in ellipsis") - } - } - } } func validateSign(sign string, signOptName string) error { if sign == "" { return fmt.Errorf("%v cannot be empty", signOptName) } - for _, r := range sign { - if !unicode.IsGraphic(r) { - return fmt.Errorf("invalid character in %v", signOptName) - } - } if runewidth.StringWidth(sign) > 2 { return fmt.Errorf("%v display width should be up to 2", signOptName) } diff --git a/src/options_test.go b/src/options_test.go index b411e58..e9cb592 100644 --- a/src/options_test.go +++ b/src/options_test.go @@ -453,8 +453,6 @@ func TestValidateSign(t *testing.T) { {"😀", true}, {"", false}, {">>>", false}, - {"\n", false}, - {"\t", false}, } for _, testCase := range testCases {