Skip to content
Myr

Fix error message on invalid --tmux option

Before adoption: this commit came in with the history the project adopted, so no landing records it.

fzf --tmux foobar # not a valid integer: foobar # -> # invalid tmux option: foobar (expected: [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]])

authored by Junegunn Choi · committed by Junegunn Choi · parent 2b6d600 · Browse files · 1 file+4 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−3 removed

  • other:+4 added−3 removed

1 file+4 added−3 removed

modified:src/options.go+4 added-3 removed
288 unmodified lines
289func parseTmuxOptions(arg string) (*tmuxOptions, error) {290 var err error291 opts := defaultTmuxOptions()292 tokens := splitRegexp.Split(arg, -1)293 errorToReturn := errors.New("invalid tmux option: " + arg + " (expected: [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]])")294 if len(tokens) == 0 || len(tokens) > 3 {294 return nil, errors.New("invalid tmux option: " + arg + " (expected: [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]])")295 return nil, errorToReturn296 }297298 // Defaults to 'center'299 switch tokens[0] {
17 unmodified lines
317 // One size given318 var size1 sizeSpec319 if len(tokens) > 1 {320 if size1, err = parseSize(tokens[1], 100, "size"); err != nil {320 return nil, err321 return nil, errorToReturn322 }323 }324325 // Two sizes given326 var size2 sizeSpec327 if len(tokens) == 3 {328 if size2, err = parseSize(tokens[2], 100, "size"); err != nil {328 return nil, err329 return nil, errorToReturn330 }331 opts.width = size1332 opts.height = size2333 } else if len(tokens) == 2 {
2564 unmodified lines