From 5525f5e89b7cc4078d2ae603e4c39f3079e1d93e Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Thu, 9 Jul 2026 13:48:52 -0400 Subject: [PATCH] tdf#151688 srchdlg: on open, repopulate Replace as well as Search When the dialog is opened, the last searched for string (from the session, not from stored config) was already restored. However, no attempt was made to restore the last replace string. Although it might feel a little dangerous to provide a restore value, it isn't really dangerous, because the user has to hit the replace button in order for it to do anything. The bug report is worried about replacing with 'nothing' by accident, so I guess the 'danger' goes both ways. Personally, I would like having both last values restored in case I accidentally closed the dialog (or closed it to get it out of the way while I manually made changes and then restarted it to continue my replace task). Only Writer replaces the 'search' content with a user's selection. In this case it seems very wise to clear the replacement string. Change-Id: Id9f40c01724978a2e51f685a60b9e3e75c21135a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207901 Reviewed-by: Justin Luth Tested-by: Jenkins --- svx/source/dialog/srchdlg.cxx | 4 ++++ sw/source/uibase/uiview/viewsrch.cxx | 1 + 2 files changed, 5 insertions(+) diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index 12f5288dc1f7..e1b2fbb1627c 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -967,7 +967,11 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern ) if (!comphelper::LibreOfficeKit::isActive()) { if (!(m_pSearchItem->GetSearchString().isEmpty()) && bSetSearch) + { m_xSearchLB->set_entry_text(m_pSearchItem->GetSearchString()); + if (bSetReplace) + m_xReplaceLB->set_entry_text(m_pSearchItem->GetReplaceString()); + } else if (!m_aSearchStrings.empty()) { bool bAttributes = ((m_pSearchList && m_pSearchList->Count()) diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index 763abf1658e7..f6e91eaf2772 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -886,6 +886,7 @@ void SwView::StateSearch(SfxItemSet &rSet) { s_pSrchItem->SetSearchString( aText ); s_pSrchItem->SetSelection( false ); + s_pSrchItem->SetReplaceString(""); } else s_pSrchItem->SetSelection( true );