Fix spell check refresh (for small documents) (#1416)

This commit is contained in:
Veronica Berglyd Olsen
2023-04-13 18:14:43 +02:00
committed by GitHub
+13 -15
View File
@@ -724,14 +724,13 @@ class GuiDocEditor(QTextEdit):
_, theProvider = self.spEnchant.describeDict() _, theProvider = self.spEnchant.describeDict()
self.spellDictionaryChanged.emit(str(theLang), str(theProvider)) self.spellDictionaryChanged.emit(str(theLang), str(theProvider))
if not self._bigDoc: if not self._bigDoc:
self.spellCheckDocument() self.spellCheckDocument()
return True return True
def toggleSpellCheck(self, theMode): def toggleSpellCheck(self, theMode):
"""This is the master spell check setting function, and this one """This is the main spell check setting function, and this one
should call all other setSpellCheck functions in other classes. should call all other setSpellCheck functions in other classes.
If the spell check mode (theMode) is not defined (None), then If the spell check mode (theMode) is not defined (None), then
toggle the current status saved in this class. toggle the current status saved in this class.
@@ -754,7 +753,8 @@ class GuiDocEditor(QTextEdit):
self.mainGui.mainMenu.setSpellCheck(theMode) self.mainGui.mainMenu.setSpellCheck(theMode)
self.theProject.data.setSpellCheck(theMode) self.theProject.data.setSpellCheck(theMode)
self.highLight.setSpellCheck(theMode) self.highLight.setSpellCheck(theMode)
if not self._bigDoc: if not self._bigDoc or theMode is False:
# We don't run the spell checker automatically on big docs
self.spellCheckDocument() self.spellCheckDocument()
logger.debug("Spell check is set to '%s'", str(theMode)) logger.debug("Spell check is set to '%s'", str(theMode))
@@ -768,18 +768,16 @@ class GuiDocEditor(QTextEdit):
the undo stack, so we only do it for big documents. the undo stack, so we only do it for big documents.
""" """
logger.debug("Running spell checker") logger.debug("Running spell checker")
if self._spellCheck: start = time()
bfTime = time() qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
qApp.setOverrideCursor(QCursor(Qt.WaitCursor)) if self._bigDoc:
if self._bigDoc: # This is much faster for large documents
theText = self.getText() self.setPlainText(self.getText())
self.setPlainText(theText) else:
else: self.highLight.rehighlight()
self.highLight.rehighlight() qApp.restoreOverrideCursor()
qApp.restoreOverrideCursor() logger.debug("Document highlighted in %.3f ms", 1000*(time() - start))
afTime = time() self.mainGui.mainStatus.setStatus(self.tr("Spell check complete"))
logger.debug("Document highlighted in %.3f ms", 1000*(afTime-bfTime))
self.mainGui.mainStatus.setStatus(self.tr("Spell check complete"))
return True return True