From 80cb0650e44e7ef580c0a33637e8abb689ed6837 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Wed, 17 Feb 2021 16:55:55 +0100 Subject: [PATCH] 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 deletion(-) diff --git a/src/frontends/qt/GuiSearch.cpp b/src/frontends/qt/GuiSearch.cpp index a9b93d8af0..0eeaf8dd75 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 50c3381e6d..a34baa3726 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; -- 2.39.2