Skip to content

Commit 3c05b6b

Browse files
committed
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. Closes #944
1 parent fb762a7 commit 3c05b6b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

completion.go

+4
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)