From f34d95edaa503556c209f30da4062dd212c72317 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Tue, 18 Oct 2022 23:49:48 +0200 Subject: [PATCH] Simplify the setText method of the Tokenizer class --- novelwriter/core/tokenizer.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/novelwriter/core/tokenizer.py b/novelwriter/core/tokenizer.py index 3a3b52f1..c55e3659 100644 --- a/novelwriter/core/tokenizer.py +++ b/novelwriter/core/tokenizer.py @@ -304,16 +304,10 @@ class Tokenizer(ABC): if self._theItem is None: return False - self._theText = "" - if theText is not None: - # If the text is set, just use that - self._theText = theText - else: - # Otherwise, load it from file - theDoc = NWDoc(self.theProject, theHandle) - theText = theDoc.readDocument() - if theText: - self._theText = theText + if theText is None: + theText = NWDoc(self.theProject, theHandle).readDocument() or "" + + self._theText = theText docSize = len(self._theText) if docSize > nwConst.MAX_DOCSIZE: