Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on spellcheck context menu #1224 #1226

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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