From 95c68156bc32ec41bb8f9741cecc6d40252be888 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Fri, 25 Aug 2017 09:39:04 -0700 Subject: [PATCH] vendor complete library --- vendor/github.com/posener/complete/command.go | 12 ++++++++++++ vendor/vendor.json | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/vendor/github.com/posener/complete/command.go b/vendor/github.com/posener/complete/command.go index eeeb9e027..6de48e960 100644 --- a/vendor/github.com/posener/complete/command.go +++ b/vendor/github.com/posener/complete/command.go @@ -49,6 +49,14 @@ type Flags map[string]Predictor // Predict completion of flags names according to command line arguments func (f Flags) Predict(a Args) (prediction []string) { for flag := range f { + // If the flag starts with a hyphen, we avoid emitting the prediction + // unless the last typed arg contains a hyphen as well. + flagHyphenStart := len(flag) != 0 && flag[0] == '-' + lastHyphenStart := len(a.Last) != 0 && a.Last[0] == '-' + if flagHyphenStart && !lastHyphenStart { + continue + } + if match.Prefix(flag, a.Last) { prediction = append(prediction, flag) } @@ -73,6 +81,10 @@ func (c *Command) predict(a Args) (options []string, only bool) { if only { return } + + // We matched so stop searching. Continuing to search can accidentally + // match a subcommand with current set of commands, see issue #46. + break } } diff --git a/vendor/vendor.json b/vendor/vendor.json index 169dee774..cebfc6acd 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -1111,10 +1111,10 @@ "revisionTime": "2016-01-10T10:55:54Z" }, { - "checksumSHA1": "6OEUkwOM0qgI6YxR+BDEn6YMvpU=", + "checksumSHA1": "rTNABfFJ9wtLQRH8uYNkEZGQOrY=", "path": "github.com/posener/complete", - "revision": "e8d6fef54b6283f8bd3fbcb4a7de8884eb540293", - "revisionTime": "2017-05-27T17:24:47Z" + "revision": "2100d1b06c06462a8a47bfc41a7f24a5d60a1420", + "revisionTime": "2017-08-25T06:44:15Z" }, { "checksumSHA1": "NB7uVS0/BJDmNu68vPAlbrq4TME=",