Skip to content

Commit 61aaf11

Browse files
dmygeroleg-jukovec
authored andcommitted
go-prompt: fix update completion data
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
1 parent c7a0bc3 commit 61aaf11

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

completion.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func (c *CompletionManager) Reset() {
6666
// Update to update the suggestions.
6767
func (c *CompletionManager) Update(in Document) {
6868
c.tmp = c.completer(in)
69+
if c.selected >= len(c.tmp) {
70+
c.selected = -1
71+
c.verticalScroll = 0
72+
}
6973
}
7074

7175
// Previous to select the previous suggestion item.

0 commit comments

Comments
 (0)