From fa9504d5956fb484e7142cb49c1ab57df7fd43d6 Mon Sep 17 00:00:00 2001 From: Alan Kilborn Date: Fri, 24 Feb 2023 08:58:24 -0500 Subject: [PATCH] Don't populate in Find what if a stream selection more than 1024 characters Avoid auto-population into "Find What" if "In Selection" is going to be auto-checkmarked. Fix #12603, close #12603 --- PowerEditor/src/NppCommands.cpp | 5 ++++- PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp | 2 +- PowerEditor/src/ScintillaComponent/FindReplaceDlg.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index c5fefb95d..85660e37f 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -1249,7 +1249,10 @@ void Notepad_plus::command(int id) if (nppGui._fillFindFieldWithSelected) { _pEditView->getGenericSelectedText(str, strSize, nppGui._fillFindFieldSelectCaret); - _findReplaceDlg.setSearchText(str); + if (lstrlen(str) <= FINDREPLACE_INSEL_TEXTSIZE_THRESHOLD) + { + _findReplaceDlg.setSearchText(str); + } } setFindReplaceFolderFilter(NULL, NULL); diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index d6c4446c0..5e2c9dc63 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -1442,7 +1442,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA if (!_options._isInSelection) { - if (nbSelected <= 1024) + if (nbSelected <= FINDREPLACE_INSEL_TEXTSIZE_THRESHOLD) { checkVal = BST_UNCHECKED; _options._isInSelection = false; diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h index 674ff5700..538c14fd2 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h @@ -28,6 +28,7 @@ #define FIND_INHIDDENDIR 2 #define FINDREPLACE_MAXLENGTH 2048 +#define FINDREPLACE_INSEL_TEXTSIZE_THRESHOLD 1024 #define FINDTEMPSTRING_MAXSIZE 1024*1024