Skip to content

Commit

Permalink
Merge pull request #75 from posener/fix-slice-bug
Browse files Browse the repository at this point in the history
Protect line slicing from index out of range
  • Loading branch information
posener authored Oct 26, 2018
2 parents ffc2cf5 + be2a7ff commit 3ef9b31
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3ef9b31

Please sign in to comment.