From d4442b9d151973b0443b7ffe24ad0a0ec28072ba Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 8 Sep 2025 16:15:01 +0200 Subject: [PATCH] Enhance Ctrl-F to copy to Find What field behaviour Fix https://github.com/notepad-plus-plus/notepad-plus-plus/pull/16976#issuecomment-3265850195 --- PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index 5b680dfe1..3cd27a9dc 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -4050,8 +4050,12 @@ void FindReplaceDlg::setSearchText(wchar_t * txt2find) if (txt2find && txt2find[0]) { // We got a valid search string - ::SendMessage(hCombo, CB_SETCURSEL, static_cast(-1), 0); // remove selection - to allow using down arrow to get to last searched word - ::SetDlgItemText(_hSelf, IDFINDWHAT, txt2find); + HWND hEdit = GetWindow(hCombo, GW_CHILD); + if (hEdit) + { + ::SendMessage(hEdit, EM_SETSEL, 0, static_cast(-1)); + ::SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)txt2find); + } } ::SendMessage(hCombo, CB_SETEDITSEL, 0, MAKELPARAM(0, -1)); // select all text - fast edit } @@ -4955,7 +4959,7 @@ LRESULT FAR PASCAL FindReplaceDlg::comboEditProc(HWND hwnd, UINT message, WPARAM HWND hEdit = GetWindow(hwndCombo, GW_CHILD); if (hEdit) { - SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)clipboardText.c_str()); + ::SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)clipboardText.c_str()); } } }