From cacb0f2db8fe7b3541548445d24ea995c9c17d09 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 26 Jul 2020 22:24:12 +0200 Subject: [PATCH] Try to capture some user edge cases --- nw/gui/doceditor.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index d961ad8c..b390fb23 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -1237,16 +1237,18 @@ class GuiDocEditor(QTextEdit): replWith = self.docSearch.getReplaceText() selText = theCursor.selectedText() + if searchFor.strip() == "": + return + if self.docSearch.doMatchCap: replWith = transferCase(selText, replWith) - if self.docSearch.isRegEx: - isMatch = True + # Double check that we have a mach in case this is called on a + # plain word selection and not on a search + if not self.docSearch.isCaseSense: + isMatch = searchFor.lower() == selText.lower() else: - if not self.docSearch.isCaseSense: - isMatch = searchFor.lower() == selText.lower() - else: - isMatch = searchFor == selText + isMatch = searchFor == selText if isMatch: theCursor.beginEditBlock() @@ -1259,8 +1261,7 @@ class GuiDocEditor(QTextEdit): searchFor, replWith, theCursor.blockNumber() )) - if searchFor: - self._findNext() + self._findNext() return