diff options
| author | Eyal Posener <[email protected]> | 2018-10-25 19:38:01 +0300 |
|---|---|---|
| committer | Eyal Posener <[email protected]> | 2018-10-25 19:38:01 +0300 |
| commit | be2a7ff2209c2880504d52f73b2e5272801d6693 (patch) | |
| tree | e5efaab6e25c864267e8297ffe3da8e5684e654d | |
| parent | ffc2cf5e958af5ac4156a886153c7cadd24a521a (diff) | |
protect line slicing from index out of range
| -rw-r--r-- | complete.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/complete.go b/complete.go index 168657e..725c4de 100644 --- a/complete.go +++ b/complete.go @@ -64,10 +64,12 @@ func (c *Complete) Complete() bool { return c.CLI.Run() } - completePhrase := line[:point] + if point >= 0 && point < len(line) { + line = line[:point] + } - Log("Completing phrase: %s", completePhrase) - a := newArgs(completePhrase) + Log("Completing phrase: %s", line) + a := newArgs(line) Log("Completing last field: %s", a.Last) options := c.Command.Predict(a) Log("Options: %s", options) |
