mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-16 10:52:29 +12:00
Fixed finding suggestions using enchant and word selection without external dictionary
This commit is contained in:
parent
cc124c0b13
commit
ad21d5faa5
|
@ -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)
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue