Skip to content

Commit

Permalink
Merge pull request #1226 from drmousse/develop
Browse files Browse the repository at this point in the history
Crash on spellcheck context menu #1224
  • Loading branch information
TheJackiMonster committed Dec 7, 2023
2 parents 1439290 + 56dac84 commit 892f8f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion manuskript/functions/spellchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def isMisspelled(self, word):

def getSuggestions(self, word):
candidates = self._dict.candidates(word)
if word in candidates:
if candidates and word in candidates:
candidates.remove(word)
return candidates

Expand Down
11 changes: 6 additions & 5 deletions manuskript/ui/views/textEditView.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,11 @@ def createStandardContextMenu(self):

selectedWord = cursor.selectedText()

for word in match.replacements:
action = self.SpellAction(word, spell_menu)
action.correct.connect(self.correctWord)
spell_menu.addAction(action)
if match.replacements:
for word in match.replacements:
action = self.SpellAction(word, spell_menu)
action.correct.connect(self.correctWord)
spell_menu.addAction(action)

# Adds: add to dictionary
addAction = QAction(self.tr("&Add to dictionary"), popup_menu)
Expand All @@ -635,7 +636,7 @@ def createStandardContextMenu(self):

# Only add the spelling suggests to the menu if there are
# suggestions.
if len(match.replacements) > 0:
if match.replacements and len(match.replacements) > 0:
# Adds: suggestions
popup_menu.insertMenu(popup_menu.actions()[0], spell_menu)
else:
Expand Down

0 comments on commit 892f8f0

Please sign in to comment.