diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index a303162b..90a671ce 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -724,14 +724,13 @@ class GuiDocEditor(QTextEdit): _, theProvider = self.spEnchant.describeDict() self.spellDictionaryChanged.emit(str(theLang), str(theProvider)) - if not self._bigDoc: self.spellCheckDocument() return True 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. If the spell check mode (theMode) is not defined (None), then toggle the current status saved in this class. @@ -754,7 +753,8 @@ class GuiDocEditor(QTextEdit): self.mainGui.mainMenu.setSpellCheck(theMode) self.theProject.data.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() 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. """ logger.debug("Running spell checker") - if self._spellCheck: - bfTime = time() - qApp.setOverrideCursor(QCursor(Qt.WaitCursor)) - if self._bigDoc: - theText = self.getText() - self.setPlainText(theText) - else: - self.highLight.rehighlight() - qApp.restoreOverrideCursor() - afTime = time() - logger.debug("Document highlighted in %.3f ms", 1000*(afTime-bfTime)) - self.mainGui.mainStatus.setStatus(self.tr("Spell check complete")) + start = time() + qApp.setOverrideCursor(QCursor(Qt.WaitCursor)) + if self._bigDoc: + # This is much faster for large documents + self.setPlainText(self.getText()) + else: + self.highLight.rehighlight() + qApp.restoreOverrideCursor() + logger.debug("Document highlighted in %.3f ms", 1000*(time() - start)) + self.mainGui.mainStatus.setStatus(self.tr("Spell check complete")) return True