Fix zero division error in spell check when list of words is empty

This commit is contained in:
Kovid Goyal 2023-07-12 07:34:23 +05:30
parent 8daa598bb9
commit 67ba227f90
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -857,9 +857,11 @@ class WordsView(QTableView):
self.verticalHeader().close()
def change_current_word_by(self, delta=1):
row = self.currentIndex().row()
row = (row + delta + self.model().rowCount()) % self.model().rowCount()
self.highlight_row(row)
rc = self.model().rowCount()
if rc > 0:
row = self.currentIndex().row()
row = (row + delta + rc) % rc
self.highlight_row(row)
def next_word(self):
self.change_current_word_by(1)