From e0fff7673d0c2ca9170c474b3cb906499c12a13b Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Fri, 15 Nov 2019 23:00:12 +0100 Subject: [PATCH] Added some more comments and debug output --- nw/gui/elements/doceditor.py | 3 +++ nw/gui/tools/dochighlight.py | 4 +++- nw/tools/spellcheck.py | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/nw/gui/elements/doceditor.py b/nw/gui/elements/doceditor.py index ab6c5ada..7cc4a186 100644 --- a/nw/gui/elements/doceditor.py +++ b/nw/gui/elements/doceditor.py @@ -530,9 +530,12 @@ class GuiDocEditor(QTextEdit): theCursor = self.cursorForPosition(thePos) theCursor.select(QTextCursor.WordUnderCursor) + theWord = theCursor.selectedText().strip().strip(self.nonWord) if theWord == "": return + + logger.verbose("Looking up '%s' in the dictionary" % theWord) if self.theDict.checkWord(theWord): return diff --git a/nw/gui/tools/dochighlight.py b/nw/gui/tools/dochighlight.py index b151ac94..270a5d15 100644 --- a/nw/gui/tools/dochighlight.py +++ b/nw/gui/tools/dochighlight.py @@ -201,12 +201,14 @@ class GuiDocHighlighter(QSyntaxHighlighter): } )) - # Build a QRegExp for each pattern and for the spell checker + # Build a QRegExp for each highlight pattern self.rxRules = [] for regEx, regRules in self.hRules: hReg = QRegularExpression(regEx) hReg.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption) self.rxRules.append((hReg, regRules)) + + # Build a QRegExp for spell checker self.spellRx = QRegularExpression(r"\b[^\s]+\b") self.spellRx.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption) diff --git a/nw/tools/spellcheck.py b/nw/tools/spellcheck.py index ec95a4f6..7979f2b9 100644 --- a/nw/tools/spellcheck.py +++ b/nw/tools/spellcheck.py @@ -13,6 +13,8 @@ import logging import nw +from os import path + from nw.constants import isoLanguage logger = logging.getLogger(__name__) @@ -75,6 +77,8 @@ class NWSpellCheck(): self.PROJW = [] if projectDict is not None: self.projectDict = projectDict + if not path.isfile(projectDict): + return try: with open(projectDict,mode="r",encoding="utf-8") as wordsFile: for theLine in wordsFile: