[LyX/master] Fix bug #12235: Select text in search field on opening.
Richard Kimberly Heck
rikiheck at lyx.org
Fri Jul 28 14:54:07 UTC 2023
commit ae5b4367d1e963353dfa5509a97ff40eb49b2c81
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date: Thu Jul 27 18:45:10 2023 -0400
Fix bug #12235: Select text in search field on opening.
Patch slightly modified from one by Daniel.
---
src/frontends/qt/GuiSearch.cpp | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/frontends/qt/GuiSearch.cpp b/src/frontends/qt/GuiSearch.cpp
index 41900d1..3ca4f49 100644
--- a/src/frontends/qt/GuiSearch.cpp
+++ b/src/frontends/qt/GuiSearch.cpp
@@ -131,8 +131,13 @@ GuiSearchWidget::GuiSearchWidget(QWidget * parent, GuiView & view)
bool GuiSearchWidget::initialiseParams(std::string const & str)
{
- if (!str.empty())
- findCO->lineEdit()->setText(toqstr(str));
+ if (!str.empty()) {
+ // selectAll & insert rather than setText in order to keep undo stack
+ findCO->lineEdit()->selectAll();
+ findCO->lineEdit()->insert(toqstr(str));
+ }
+ findCO->setFocus();
+ findCO->lineEdit()->selectAll();
return true;
}
@@ -409,8 +414,6 @@ void GuiSearchWidget::wrapActTriggered()
void GuiSearchWidget::showEvent(QShowEvent * e)
{
findChanged();
- findPB->setFocus();
- findCO->lineEdit()->selectAll();
QWidget::showEvent(e);
}
@@ -432,9 +435,9 @@ void GuiSearchWidget::findBufferChanged()
// might end up in loops with search as you type)
if (!search.empty() && toqstr(search) != findCO->lineEdit()->text()) {
LYXERR(Debug::CLIPBOARD, "from findbuffer: " << search);
+ // selectAll & insert rather than setText in order to keep undo stack
findCO->lineEdit()->selectAll();
findCO->lineEdit()->insert(toqstr(search));
- findCO->lineEdit()->selectAll();
}
}
More information about the lyx-cvs
mailing list