From ae5b4367d1e963353dfa5509a97ff40eb49b2c81 Mon Sep 17 00:00:00 2001 From: Richard Kimberly Heck Date: Thu, 27 Jul 2023 18:45:10 -0400 Subject: [PATCH] Fix bug #12235: Select text in search field on opening. Patch slightly modified from one by Daniel. --- src/frontends/qt/GuiSearch.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/frontends/qt/GuiSearch.cpp b/src/frontends/qt/GuiSearch.cpp index 41900d1a05..3ca4f4904d 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(); } } -- 2.39.5