Make some minor improvements to spell check suggest
This commit is contained in:
@@ -1043,7 +1043,7 @@ class GuiDocEditor(QPlainTextEdit):
|
||||
if suggest:
|
||||
ctxMenu.addSeparator()
|
||||
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.triggered.connect(
|
||||
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.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))
|
||||
ctxMenu.addAction(aAdd)
|
||||
|
||||
# Execute the context menu
|
||||
ctxMenu.exec_(self.viewport().mapToGlobal(pos))
|
||||
|
||||
@@ -101,17 +101,16 @@ class GuiTextDocument(QTextDocument):
|
||||
cursor = QTextCursor(self)
|
||||
cursor.setPosition(pos)
|
||||
block = cursor.block()
|
||||
if block.isValid():
|
||||
data = block.userData()
|
||||
if isinstance(data, TextBlockData):
|
||||
text = block.text()
|
||||
check = pos - block.position()
|
||||
if check >= 0:
|
||||
for cPos, cLen in data.spellErrors:
|
||||
cEnd = cPos + cLen
|
||||
if cPos <= check <= cEnd:
|
||||
word = text[cPos:cEnd]
|
||||
return word, cPos, cLen, SHARED.spelling.suggestWords(word)
|
||||
data = block.userData()
|
||||
if block.isValid() and isinstance(data, TextBlockData):
|
||||
text = block.text()
|
||||
check = pos - block.position()
|
||||
if check >= 0:
|
||||
for cPos, cLen in data.spellErrors:
|
||||
cEnd = cPos + cLen
|
||||
if cPos <= check <= cEnd:
|
||||
word = text[cPos:cEnd]
|
||||
return word, cPos, cLen, SHARED.spelling.suggestWords(word)
|
||||
return "", -1, -1, []
|
||||
|
||||
# END Class GuiTextDocument
|
||||
|
||||
Reference in New Issue
Block a user