Merge pull request #1226 from drmousse/develop

Crash on spellcheck context menu #1224
This commit is contained in:
Tobias Frisch 2023-12-07 15:35:59 +01:00 committed by GitHub
commit 892f8f0592
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -363,7 +363,7 @@ class PySpellcheckerDictionary(BasicDictionary):
def getSuggestions(self, word): def getSuggestions(self, word):
candidates = self._dict.candidates(word) candidates = self._dict.candidates(word)
if word in candidates: if candidates and word in candidates:
candidates.remove(word) candidates.remove(word)
return candidates return candidates

View file

@ -620,10 +620,11 @@ class textEditView(QTextEdit):
selectedWord = cursor.selectedText() selectedWord = cursor.selectedText()
for word in match.replacements: if match.replacements:
action = self.SpellAction(word, spell_menu) for word in match.replacements:
action.correct.connect(self.correctWord) action = self.SpellAction(word, spell_menu)
spell_menu.addAction(action) action.correct.connect(self.correctWord)
spell_menu.addAction(action)
# Adds: add to dictionary # Adds: add to dictionary
addAction = QAction(self.tr("&Add to dictionary"), popup_menu) addAction = QAction(self.tr("&Add to dictionary"), popup_menu)
@ -635,7 +636,7 @@ class textEditView(QTextEdit):
# Only add the spelling suggests to the menu if there are # Only add the spelling suggests to the menu if there are
# suggestions. # suggestions.
if len(match.replacements) > 0: if match.replacements and len(match.replacements) > 0:
# Adds: suggestions # Adds: suggestions
popup_menu.insertMenu(popup_menu.actions()[0], spell_menu) popup_menu.insertMenu(popup_menu.actions()[0], spell_menu)
else: else: