Fix error with hidden suggestions

Avoid indexing a nil if there are no suggestions.
This commit is contained in:
Francesco Abbate 2021-09-07 18:07:26 +02:00 committed by Francesco
parent f85fe102d9
commit 4bcc1cc07c
1 changed files with 1 additions and 1 deletions

View File

@ -89,7 +89,7 @@ end
function CommandView:move_suggestion_idx(dir) function CommandView:move_suggestion_idx(dir)
local current_suggestion = self.suggestions[self.suggestion_idx].text local current_suggestion = #self.suggestions > 0 and self.suggestions[self.suggestion_idx].text
if self.show_suggestions or self:get_text() == current_suggestion then if self.show_suggestions or self:get_text() == current_suggestion then
local n = self.suggestion_idx + dir local n = self.suggestion_idx + dir
self.suggestion_idx = common.clamp(n, 1, #self.suggestions) self.suggestion_idx = common.clamp(n, 1, #self.suggestions)