Fixed finding suggestions using enchant and word selection without external dictionary

This commit is contained in:
TheJackiMonster 2021-02-22 01:13:19 +01:00
parent cc124c0b13
commit ad21d5faa5
No known key found for this signature in database
GPG key ID: D850A5F772E880F9
2 changed files with 5 additions and 6 deletions

View file

@ -297,9 +297,6 @@ class EnchantDictionary(BasicDictionary):
def getSuggestions(self, word):
return self._dict.suggest(word)
def findSuggestions(self, text, start, end):
return []
def isCustomWord(self, word):
return self._dict.is_added(word)

View file

@ -490,14 +490,14 @@ class textEditView(QTextEdit):
selectedWord = None
# Check for any suggestions for corrections at the cursors position
if self._dict:
if self._dict != None:
text = self.toPlainText()
suggestions = self._dict.findSuggestions(text, cursor.selectionStart(), cursor.selectionEnd())
# Select the word under the cursor if necessary.
# But only if there is no selection (otherwise it's impossible to select more text to copy/cut)
if (not cursor.hasSelection() and len(suggestions) == 0):
if not cursor.hasSelection() and len(suggestions) == 0:
cursor.select(QTextCursor.WordUnderCursor)
self.setTextCursor(cursor)
@ -507,8 +507,10 @@ class textEditView(QTextEdit):
# Check if the selected word is misspelled and offer spelling
# suggestions if it is.
suggestions = self._dict.findSuggestions(text, cursor.selectionStart(), cursor.selectionEnd())
elif cursor.hasSelection():
selectedWord = cursor.selectedText()
if (len(suggestions) > 0 or selectedWord):
if len(suggestions) > 0 or selectedWord != None:
valid = len(suggestions) == 0
if not valid: