Skip to content

Commit

Permalink
go-prompt: fix update completion data
Browse files Browse the repository at this point in the history
The issue that in `GetSelectedSuggestion()` there is no checks
that index in valid range. So here we are resetting `selected` index,
if length of new array is less, than it was.

Part of tarantool/tt#944
  • Loading branch information
dmyger authored and oleg-jukovec committed Oct 8, 2024
1 parent c7a0bc3 commit 61aaf11
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func (c *CompletionManager) Reset() {
// Update to update the suggestions.
func (c *CompletionManager) Update(in Document) {
c.tmp = c.completer(in)
if c.selected >= len(c.tmp) {
c.selected = -1
c.verticalScroll = 0
}
}

// Previous to select the previous suggestion item.
Expand Down

0 comments on commit 61aaf11

Please sign in to comment.