From 9dd8f657953d23328439555bbffe5c8bccc94374 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Tue, 17 Oct 2023 20:25:17 +0200 Subject: [PATCH] Clean up a few bits in the editor code, fix margins, and fix issue in spell checker --- novelwriter/gui/doceditor.py | 14 ++------------ novelwriter/gui/dochighlight.py | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index 60c7b00e..525fd179 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -95,8 +95,6 @@ class GuiDocEditor(QPlainTextEdit): self._docChanged = False # Flag for changed status of document self._docHandle = None # The handle of the open document - - self._nonWord = "\"'" # Characters to not include in spell checking self._vpMargin = 0 # The editor viewport margin, set during init # Document Variables @@ -271,13 +269,6 @@ class GuiDocEditor(QPlainTextEdit): settings. This function is both called when the editor is created, and when the user changes the main editor preferences. """ - # Some Constants - self._nonWord = ( - "\"'" - f"{CONFIG.fmtSQuoteOpen}{CONFIG.fmtSQuoteClose}" - f"{CONFIG.fmtDQuoteOpen}{CONFIG.fmtDQuoteClose}" - ) - # Typography if CONFIG.fmtPadThin: self._typPadChar = nwUnicode.U_THNBSP @@ -307,9 +298,8 @@ class GuiDocEditor(QPlainTextEdit): # Set default text margins # Due to cursor visibility, a part of the margin must be # allocated to the document itself. See issue #1112. - cW = 2*self.cursorWidth() - self._qDocument.setDocumentMargin(cW) - self._vpMargin = max(CONFIG.getTextMargin() - cW, 0) + self._qDocument.setDocumentMargin(4) + self._vpMargin = max(CONFIG.getTextMargin() - 4, 0) self.setViewportMargins(self._vpMargin, self._vpMargin, self._vpMargin, self._vpMargin) # Also set the document text options for the document text flow diff --git a/novelwriter/gui/dochighlight.py b/novelwriter/gui/dochighlight.py index 64d1f34e..5acd7ef7 100644 --- a/novelwriter/gui/dochighlight.py +++ b/novelwriter/gui/dochighlight.py @@ -452,7 +452,7 @@ class TextBlockData(QTextBlockUserData): while rxSpell.hasNext(): rxMatch = rxSpell.next() if not SHARED.spelling.checkWord(rxMatch.captured(0)): - if rxMatch.captured(0).isalpha() and not rxMatch.captured(0).isupper(): + if not rxMatch.captured(0).isnumeric() and not rxMatch.captured(0).isupper(): self._spellErrors.append((rxMatch.capturedStart(0), rxMatch.capturedLength(0))) return self._spellErrors