From d7e485af0588e2a4c3646f37d5bdd17fb7358194 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 6 Oct 2019 15:51:46 +0200 Subject: [PATCH] Some improvements to replace action --- nw/gui/doceditor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 5e0bc81c..8018438c 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -504,6 +504,7 @@ class GuiDocEditor(QTextEdit): def _beginReplace(self): """Opens the replace line of the search bar and sets the replace text. """ + self._beginSearch() self.theParent.searchBar.setReplaceText("") return @@ -536,8 +537,9 @@ class GuiDocEditor(QTextEdit): with the replace text. Wraps back to the top if not found. """ theCursor = self.textCursor() + searchFor = self.theParent.searchBar.getSearchText() replWith = self.theParent.searchBar.getReplaceText() - if theCursor.hasSelection(): + if theCursor.hasSelection() and theCursor.selectedText() == searchFor: xPos = theCursor.selectionStart() theCursor.beginEditBlock() theCursor.removeSelectedText() @@ -545,7 +547,8 @@ class GuiDocEditor(QTextEdit): theCursor.endEditBlock() theCursor.setPosition(xPos) self.setTextCursor(theCursor) - self._findNext() + if searchFor != "": + self._findNext() return # END Class GuiDocEditor