diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2024-05-31 13:38:39 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-05-31 16:57:35 +0900 |
| commit | 7aa88aa115a093b89b5d73ffab79ccf27c6a0ae8 (patch) | |
| tree | 1a41642093cb779269d502fcf788dc5236ef9733 | |
| parent | 2b6d600879278f771e0ae909b38ecaaab62bc9c1 (diff) | |
| download | fzf-7aa88aa115a093b89b5d73ffab79ccf27c6a0ae8.tar.gz | |
Fix error message on invalid --tmux option
fzf --tmux foobar
# not a valid integer: foobar
# ->
# invalid tmux option: foobar (expected: [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]])
| -rw-r--r-- | src/options.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/options.go b/src/options.go index 8b77d950..18e40409 100644 --- a/src/options.go +++ b/src/options.go @@ -290,8 +290,9 @@ func parseTmuxOptions(arg string) (*tmuxOptions, error) { var err error opts := defaultTmuxOptions() tokens := splitRegexp.Split(arg, -1) + errorToReturn := errors.New("invalid tmux option: " + arg + " (expected: [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]])") if len(tokens) == 0 || len(tokens) > 3 { - return nil, errors.New("invalid tmux option: " + arg + " (expected: [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]])") + return nil, errorToReturn } // Defaults to 'center' @@ -317,7 +318,7 @@ func parseTmuxOptions(arg string) (*tmuxOptions, error) { var size1 sizeSpec if len(tokens) > 1 { if size1, err = parseSize(tokens[1], 100, "size"); err != nil { - return nil, err + return nil, errorToReturn } } @@ -325,7 +326,7 @@ func parseTmuxOptions(arg string) (*tmuxOptions, error) { var size2 sizeSpec if len(tokens) == 3 { if size2, err = parseSize(tokens[2], 100, "size"); err != nil { - return nil, err + return nil, errorToReturn } opts.width = size1 opts.height = size2 |
