Make some minor improvements to spell check suggest
This commit is contained in:
@@ -1043,7 +1043,7 @@ class GuiDocEditor(QPlainTextEdit):
|
|||||||
if suggest:
|
if suggest:
|
||||||
ctxMenu.addSeparator()
|
ctxMenu.addSeparator()
|
||||||
ctxMenu.addAction(self.tr("Spelling Suggestion(s)"))
|
ctxMenu.addAction(self.tr("Spelling Suggestion(s)"))
|
||||||
for option in suggest:
|
for option in suggest[:15]:
|
||||||
aFix = ctxMenu.addAction(f"{nwUnicode.U_ENDASH} {option}")
|
aFix = ctxMenu.addAction(f"{nwUnicode.U_ENDASH} {option}")
|
||||||
aFix.triggered.connect(
|
aFix.triggered.connect(
|
||||||
lambda _, option=option: self._correctWord(sCursor, option)
|
lambda _, option=option: self._correctWord(sCursor, option)
|
||||||
@@ -1052,9 +1052,8 @@ class GuiDocEditor(QPlainTextEdit):
|
|||||||
ctxMenu.addAction("%s %s" % (nwUnicode.U_ENDASH, self.tr("No Suggestions")))
|
ctxMenu.addAction("%s %s" % (nwUnicode.U_ENDASH, self.tr("No Suggestions")))
|
||||||
|
|
||||||
ctxMenu.addSeparator()
|
ctxMenu.addSeparator()
|
||||||
aAdd = QAction(self.tr("Add Word to Dictionary"), ctxMenu)
|
aAdd = ctxMenu.addAction(self.tr("Add Word to Dictionary"))
|
||||||
aAdd.triggered.connect(lambda: self._addWord(word, block))
|
aAdd.triggered.connect(lambda: self._addWord(word, block))
|
||||||
ctxMenu.addAction(aAdd)
|
|
||||||
|
|
||||||
# Execute the context menu
|
# Execute the context menu
|
||||||
ctxMenu.exec_(self.viewport().mapToGlobal(pos))
|
ctxMenu.exec_(self.viewport().mapToGlobal(pos))
|
||||||
|
|||||||
@@ -101,17 +101,16 @@ class GuiTextDocument(QTextDocument):
|
|||||||
cursor = QTextCursor(self)
|
cursor = QTextCursor(self)
|
||||||
cursor.setPosition(pos)
|
cursor.setPosition(pos)
|
||||||
block = cursor.block()
|
block = cursor.block()
|
||||||
if block.isValid():
|
data = block.userData()
|
||||||
data = block.userData()
|
if block.isValid() and isinstance(data, TextBlockData):
|
||||||
if isinstance(data, TextBlockData):
|
text = block.text()
|
||||||
text = block.text()
|
check = pos - block.position()
|
||||||
check = pos - block.position()
|
if check >= 0:
|
||||||
if check >= 0:
|
for cPos, cLen in data.spellErrors:
|
||||||
for cPos, cLen in data.spellErrors:
|
cEnd = cPos + cLen
|
||||||
cEnd = cPos + cLen
|
if cPos <= check <= cEnd:
|
||||||
if cPos <= check <= cEnd:
|
word = text[cPos:cEnd]
|
||||||
word = text[cPos:cEnd]
|
return word, cPos, cLen, SHARED.spelling.suggestWords(word)
|
||||||
return word, cPos, cLen, SHARED.spelling.suggestWords(word)
|
|
||||||
return "", -1, -1, []
|
return "", -1, -1, []
|
||||||
|
|
||||||
# END Class GuiTextDocument
|
# END Class GuiTextDocument
|
||||||
|
|||||||
Reference in New Issue
Block a user