From 8c3e906fc5d47ab4120d9a7a0d6ffee3b9c4d488 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:56:39 +0200 Subject: [PATCH] Remove the big doc limit feature --- novelwriter/config.py | 3 -- novelwriter/dialogs/preferences.py | 17 +------ novelwriter/gui/doceditor.py | 44 +------------------ tests/reference/baseConfig_novelwriter.conf | 1 - .../reference/guiPreferences_novelwriter.conf | 1 - tests/test_dialogs/test_dlg_preferences.py | 3 -- tests/test_gui/test_gui_doceditor.py | 6 --- 7 files changed, 3 insertions(+), 72 deletions(-) diff --git a/novelwriter/config.py b/novelwriter/config.py index d0bd7fc3..526938de 100644 --- a/novelwriter/config.py +++ b/novelwriter/config.py @@ -149,7 +149,6 @@ class Config: self.autoScrollPos = 30 # Start point for typewriter-like scrolling self.wordCountTimer = 5.0 # Interval for word count update in seconds - self.bigDocLimit = 800 # Size threshold for heavy editor features in kilobytes self.incNotesWCount = True # The status bar word count includes notes self.highlightQuotes = True # Highlight text in quotes @@ -588,7 +587,6 @@ class Config: self.showLineEndings = conf.rdBool(sec, "showlineendings", self.showLineEndings) self.showMultiSpaces = conf.rdBool(sec, "showmultispaces", self.showMultiSpaces) self.wordCountTimer = conf.rdFlt(sec, "wordcounttimer", self.wordCountTimer) - self.bigDocLimit = conf.rdInt(sec, "bigdoclimit", self.bigDocLimit) self.incNotesWCount = conf.rdBool(sec, "incnoteswcount", self.incNotesWCount) self.showFullPath = conf.rdBool(sec, "showfullpath", self.showFullPath) self.highlightQuotes = conf.rdBool(sec, "highlightquotes", self.highlightQuotes) @@ -712,7 +710,6 @@ class Config: "showlineendings": str(self.showLineEndings), "showmultispaces": str(self.showMultiSpaces), "wordcounttimer": str(self.wordCountTimer), - "bigdoclimit": str(self.bigDocLimit), "incnoteswcount": str(self.incNotesWCount), "showfullpath": str(self.showFullPath), "highlightquotes": str(self.highlightQuotes), diff --git a/novelwriter/dialogs/preferences.py b/novelwriter/dialogs/preferences.py index 72120448..24bee775 100644 --- a/novelwriter/dialogs/preferences.py +++ b/novelwriter/dialogs/preferences.py @@ -675,19 +675,6 @@ class GuiPreferencesEditor(QWidget): self.tr("Available languages are determined by your system.") ) - # Big Document Size Limit - self.bigDocLimit = QSpinBox(self) - self.bigDocLimit.setMinimum(10) - self.bigDocLimit.setMaximum(10000) - self.bigDocLimit.setSingleStep(10) - self.bigDocLimit.setValue(CONFIG.bigDocLimit) - self.mainForm.addRow( - self.tr("Big document limit"), - self.bigDocLimit, - self.tr("Full spell checking is disabled above this limit."), - unit=self.tr("kB") - ) - # Word Count # ========== self.mainForm.addGroupLabel(self.tr("Word Count")) @@ -775,11 +762,9 @@ class GuiPreferencesEditor(QWidget): return def saveValues(self): - """Save the values set for this tab. - """ + """Save the values set for this tab.""" # Spell Checking CONFIG.spellLanguage = self.spellLanguage.currentData() - CONFIG.bigDocLimit = self.bigDocLimit.value() # Word Count CONFIG.wordCountTimer = self.wordCountTimer.value() diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index 5e8ffb25..cf018b56 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -106,7 +106,6 @@ class GuiDocEditor(QPlainTextEdit): self._lastEdit = 0 # Time stamp of last edit self._lastActive = 0.0 # Time stamp of last activity self._lastFind = None # Position of the last found search word - self._bigDoc = False # Flag for very large document size self._doReplace = False # Switch to temporarily disable auto-replace self._queuePos = None # Used for delayed change of cursor position @@ -238,7 +237,6 @@ class GuiDocEditor(QPlainTextEdit): self._lastEdit = 0 self._lastActive = 0.0 self._lastFind = None - self._bigDoc = False self._doReplace = False self._queuePos = None @@ -396,13 +394,6 @@ class GuiDocEditor(QPlainTextEdit): qApp.setOverrideCursor(QCursor(Qt.WaitCursor)) self.highLight.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(docSize) - spTemp = self.highLight.spellCheck - if self._bigDoc: - self.highLight.setSpellCheck(False) - bfTime = time() self._allowAutoReplace(False) self.setPlainText(theDoc) @@ -422,7 +413,6 @@ class GuiDocEditor(QPlainTextEdit): self.docHeader.setTitleFromHandle(self._docHandle) self.docFooter.setHandle(self._docHandle) self.updateDocMargins() - self.highLight.setSpellCheck(spTemp) if tLine is None and self._nwItem is not None: # For large documents, we queue the repositioning until the @@ -714,8 +704,7 @@ class GuiDocEditor(QPlainTextEdit): self.mainGui.mainMenu.setSpellCheck(state) SHARED.project.data.setSpellCheck(state) self.highLight.setSpellCheck(state) - if not self._bigDoc or state is False: - # We don't run the spell checker automatically on big docs + if state is False: self.spellCheckDocument() logger.debug("Spell check is set to '%s'", str(state)) @@ -731,11 +720,7 @@ class GuiDocEditor(QPlainTextEdit): logger.debug("Running spell checker") 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() + self.highLight.rehighlight() qApp.restoreOverrideCursor() logger.debug("Document highlighted in %.3f ms", 1000*(time() - start)) self.statusMessage.emit(self.tr("Spell check complete")) @@ -1261,8 +1246,6 @@ class GuiDocEditor(QPlainTextEdit): # Must not be emitted if docHandle is None! self.docCountsChanged.emit(self._docHandle, cCount, wCount, pCount) - - self._checkDocSize(self.document().characterCount()) self.docFooter.updateCounts() return @@ -2022,29 +2005,6 @@ class GuiDocEditor(QPlainTextEdit): return False return True - def _checkDocSize(self, size: int) -> None: - """Check if document size crosses the big document limit set in - config. If so, we will set the big document flag to True. - """ - bigLim = round(CONFIG.bigDocLimit*1000) - newState = size > bigLim - - if newState != self._bigDoc: - if newState: - logger.info( - f"The document size is {size:n} > {bigLim:n}, " - f"big doc mode has been enabled" - ) - else: - logger.info( - f"The document size is {size:n} <= {bigLim:n}, " - f"big doc mode has been disabled" - ) - - self._bigDoc = newState - - return - def _autoSelect(self) -> QTextCursor: """Return a cursor which may or may not have a selection based on user settings and document action. diff --git a/tests/reference/baseConfig_novelwriter.conf b/tests/reference/baseConfig_novelwriter.conf index e1554e94..2f4b05e1 100644 --- a/tests/reference/baseConfig_novelwriter.conf +++ b/tests/reference/baseConfig_novelwriter.conf @@ -58,7 +58,6 @@ showtabsnspaces = False showlineendings = False showmultispaces = True wordcounttimer = 5.0 -bigdoclimit = 800 incnoteswcount = True showfullpath = True highlightquotes = True diff --git a/tests/reference/guiPreferences_novelwriter.conf b/tests/reference/guiPreferences_novelwriter.conf index de16e4e6..a8700427 100644 --- a/tests/reference/guiPreferences_novelwriter.conf +++ b/tests/reference/guiPreferences_novelwriter.conf @@ -58,7 +58,6 @@ showtabsnspaces = True showlineendings = True showmultispaces = True wordcounttimer = 5.0 -bigdoclimit = 500 incnoteswcount = True showfullpath = False highlightquotes = False diff --git a/tests/test_dialogs/test_dlg_preferences.py b/tests/test_dialogs/test_dlg_preferences.py index 14712795..fe6b807a 100644 --- a/tests/test_dialogs/test_dlg_preferences.py +++ b/tests/test_dialogs/test_dlg_preferences.py @@ -159,9 +159,6 @@ def testDlgPreferences_Main(qtbot, monkeypatch, nwGUI, tstPaths): qtbot.wait(KEY_DELAY) tabEditor.scrollPastEnd.setValue(0) - qtbot.wait(KEY_DELAY) - tabEditor.bigDocLimit.setValue(500) - # Syntax Settings qtbot.wait(KEY_DELAY) tabSyntax = nwPrefs.tabSyntax diff --git a/tests/test_gui/test_gui_doceditor.py b/tests/test_gui/test_gui_doceditor.py index 2e0c046f..7e3cbc26 100644 --- a/tests/test_gui/test_gui_doceditor.py +++ b/tests/test_gui/test_gui_doceditor.py @@ -104,7 +104,6 @@ def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumTex # Regular open assert nwGUI.docEditor.loadText(C.hSceneDoc) is True - assert nwGUI.docEditor._bigDoc is False # Reload too big text with monkeypatch.context() as mp: @@ -112,11 +111,6 @@ def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumTex assert nwGUI.docEditor.replaceText(longText) is False assert "The document you are trying to open is too big." in caplog.text - # Big doc handling - CONFIG.bigDocLimit = 50 - assert nwGUI.docEditor.loadText(C.hSceneDoc) is True - assert nwGUI.docEditor._bigDoc is True - # Regular open, with line number (1 indexed) assert nwGUI.docEditor.loadText(C.hSceneDoc, tLine=4) is True cursPos = nwGUI.docEditor.getCursorPosition()