diff options
| author | Eyal Posener <[email protected]> | 2019-10-23 22:46:40 +0300 |
|---|---|---|
| committer | Eyal Posener <[email protected]> | 2019-10-23 22:49:48 +0300 |
| commit | f7264fe38585e1c6efe68ea27bc27747fc21cf84 (patch) | |
| tree | f2a8af9bf26cb8fca022da1246268969adc2d7ef /args.go | |
| parent | e24ae2ec882eef4b8d9f42177fd026d3db4bdb73 (diff) | |
fix off-by-one error for sub command completion.
Fixes #97
Diffstat (limited to 'args.go')
| -rw-r--r-- | args.go | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -85,16 +85,17 @@ func splitLastEqual(line []string) []string { return append(line[:len(line)-1], parts...) } +// from returns a copy of Args of all arguments after the i'th argument. func (a Args) from(i int) Args { - if i > len(a.All) { - i = len(a.All) + if i >= len(a.All) { + i = len(a.All) - 1 } - a.All = a.All[i:] + a.All = a.All[i+1:] - if i > len(a.Completed) { - i = len(a.Completed) + if i >= len(a.Completed) { + i = len(a.Completed) - 1 } - a.Completed = a.Completed[i:] + a.Completed = a.Completed[i+1:] return a } |
