Disable initial spell checking for large documents
This commit is contained in:
@@ -93,6 +93,7 @@ class Config:
|
||||
self.wordCountTimer = 5.0
|
||||
self.showTabsNSpaces = False
|
||||
self.showLineEndings = False
|
||||
self.bigDocLimit = 800
|
||||
|
||||
self.fmtApostrophe = nwUnicode.U_RSQUO
|
||||
self.fmtSingleQuotes = [nwUnicode.U_LSQUO,nwUnicode.U_RSQUO]
|
||||
|
||||
@@ -53,6 +53,7 @@ class GuiDocEditor(QTextEdit):
|
||||
self.wordCount = 0
|
||||
self.paraCount = 0
|
||||
self.lastEdit = 0
|
||||
self.bigDoc = False
|
||||
self.nonWord = "\"'"
|
||||
|
||||
# Typography
|
||||
@@ -114,17 +115,22 @@ class GuiDocEditor(QTextEdit):
|
||||
return
|
||||
|
||||
def clearEditor(self):
|
||||
"""Clear the current document and reset all document related
|
||||
flags and counters.
|
||||
"""
|
||||
|
||||
self.nwDocument.clearDocument()
|
||||
self.setReadOnly(True)
|
||||
self.clear()
|
||||
self.wcTimer.stop()
|
||||
|
||||
self.theHandle = None
|
||||
self.charCount = 0
|
||||
self.wordCount = 0
|
||||
self.paraCount = 0
|
||||
self.lastEdit = 0
|
||||
self.theHandle = None
|
||||
self.charCount = 0
|
||||
self.wordCount = 0
|
||||
self.paraCount = 0
|
||||
self.lastEdit = 0
|
||||
self.bigDoc = False
|
||||
|
||||
self.hasSelection = False
|
||||
|
||||
self.setDocumentChanged(False)
|
||||
@@ -214,8 +220,12 @@ class GuiDocEditor(QTextEdit):
|
||||
return False
|
||||
|
||||
self.hLight.setHandle(tHandle)
|
||||
|
||||
# Check that the document is not too big for full, initial spell
|
||||
# checking. If it is too big, we switch to only check as we type
|
||||
self._checkDocSize(len(theDoc))
|
||||
spTemp = self.hLight.spellCheck
|
||||
self.hLight.spellCheck = False
|
||||
self.hLight.spellCheck = not self.bigDoc
|
||||
|
||||
bfTime = time()
|
||||
self.setPlainText(theDoc)
|
||||
@@ -696,9 +706,24 @@ class GuiDocEditor(QTextEdit):
|
||||
self.theParent.statusBar.setCounts(self.charCount,self.wordCount,self.paraCount)
|
||||
self.theParent.treeView.propagateCount(tHandle, self.wordCount)
|
||||
self.theParent.treeView.projectWordCount()
|
||||
self._checkDocSize(self.charCount)
|
||||
|
||||
return
|
||||
|
||||
def _checkDocSize(self, theSize):
|
||||
"""Check if document size crosses the big document limit set in
|
||||
config. If so, we will set the big document flag to True.
|
||||
"""
|
||||
if theSize > self.mainConf.bigDocLimit*1000:
|
||||
logger.info(
|
||||
"The document size is %d > %d, big doc mode is enabled" % (
|
||||
theSize, self.mainConf.bigDocLimit*1000
|
||||
))
|
||||
self.bigDoc = True
|
||||
else:
|
||||
self.bigDoc = False
|
||||
return
|
||||
|
||||
def _wrapSelection(self, tBefore, tAfter):
|
||||
"""Wraps the selected text in whatever is in tBefore and tAfter.
|
||||
If there is no selection, the autoSelect setting decides the
|
||||
|
||||
Reference in New Issue
Block a user