[LyX/master] Clean up previous selections with empty searchstr on instant

Juergen Spitzmueller spitz at lyx.org
Wed Feb 17 15:53:49 UTC 2021


commit 80cb0650e44e7ef580c0a33637e8abb689ed6837
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Wed Feb 17 16:55:55 2021 +0100

    Clean up previous selections with empty searchstr on instant
---
 src/frontends/qt/GuiSearch.cpp |    2 +-
 src/lyxfind.cpp                |    9 +++++++++
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/frontends/qt/GuiSearch.cpp b/src/frontends/qt/GuiSearch.cpp
index a9b93d8..0eeaf8d 100644
--- a/src/frontends/qt/GuiSearch.cpp
+++ b/src/frontends/qt/GuiSearch.cpp
@@ -193,7 +193,7 @@ void GuiSearchWidget::findChanged()
 	replacePB->setEnabled(replace);
 	replacePrevPB->setEnabled(replace);
 	replaceallPB->setEnabled(replace);
-	if (instantSearchCB->isChecked() && !emptytext)
+	if (instantSearchCB->isChecked())
 		doFind(false, true);
 }
 
diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 50c3381..a34baa3 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -279,6 +279,15 @@ bool findOne(BufferView * bv, docstring const & searchstr,
 	     bool find_del, bool check_wrap, bool auto_wrap,
 	     bool instant, bool onlysel)
 {
+	// Clean up previous selections with empty searchstr on instant
+	if (searchstr.empty() && instant) {
+		if (bv->cursor().selection()) {
+			bv->setCursor(bv->cursor().selectionBegin());
+			bv->clearSelection();
+		}
+		return false;
+	}
+
 	if (!searchAllowed(searchstr))
 		return false;
 


More information about the lyx-cvs mailing list