diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml
index a80b5668f..ebf54e536 100644
--- a/PowerEditor/installer/nativeLang/english.xml
+++ b/PowerEditor/installer/nativeLang/english.xml
@@ -1524,6 +1524,10 @@ Would you like to create those placeholders?
NOTE: Choosing not to create the placeholders or closing them later, your session WILL BE MODIFIED ON EXIT! We suggest you backup your "session.xml" now."/>
+
diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml
index 52321ab92..288507d06 100644
--- a/PowerEditor/installer/nativeLang/english_customizable.xml
+++ b/PowerEditor/installer/nativeLang/english_customizable.xml
@@ -1524,6 +1524,10 @@ Would you like to create those placeholders?
NOTE: Choosing not to create the placeholders or closing them later, your session WILL BE MODIFIED ON EXIT! We suggest you backup your "session.xml" now."/>
+
diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp
index d920dcab7..b5e9aa578 100644
--- a/PowerEditor/src/Notepad_plus.cpp
+++ b/PowerEditor/src/Notepad_plus.cpp
@@ -601,6 +601,12 @@ LRESULT Notepad_plus::init(HWND hwnd)
//Search menu
//disable "Search Results Window" under Search Menu
::EnableMenuItem(_mainMenuHandle, IDM_FOCUS_ON_FOUND_RESULTS, MF_DISABLED | MF_GRAYED | MF_BYCOMMAND);
+ ::EnableMenuItem(_mainMenuHandle, IDM_SEARCH_GOTONEXTFOUND, MF_DISABLED | MF_GRAYED | MF_BYCOMMAND);
+ ::EnableMenuItem(_mainMenuHandle, IDM_SEARCH_GOTOPREVFOUND, MF_DISABLED | MF_GRAYED | MF_BYCOMMAND);
+
+ // Find dialog is not created yet
+ ::EnableMenuItem(_mainMenuHandle, IDM_SEARCH_FINDNEXT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
+ ::EnableMenuItem(_mainMenuHandle, IDM_SEARCH_FINDPREV, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
//Main menu is loaded, now load editor context menu items
nppParam.getContextMenuFromXmlTree(_mainMenuHandle, _pluginsManager.getMenuHandle());
diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp
index 88bd0ceb8..d8e62828e 100644
--- a/PowerEditor/src/NppCommands.cpp
+++ b/PowerEditor/src/NppCommands.cpp
@@ -1367,6 +1367,8 @@ void Notepad_plus::command(int id)
{
// regex upward search is disabled
// make this a no-action command
+
+ _findReplaceDlg.regexBackwardMsgBox();
}
else
{
diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
index 782ca4197..821d22824 100644
--- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
+++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
@@ -1835,9 +1835,12 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
case IDM_SEARCH_FINDNEXT:
case IDM_SEARCH_FINDPREV:
{
- if (HIWORD(wParam) != 1 ||
- (getCurrentStatus() != DIALOG_TYPE::FIND_DLG &&
- getCurrentStatus() != DIALOG_TYPE::REPLACE_DLG))
+ if (HIWORD(wParam) != 1 ||
+ (getCurrentStatus() != DIALOG_TYPE::FIND_DLG &&
+ getCurrentStatus() != DIALOG_TYPE::REPLACE_DLG)
+ || (LOWORD(wParam) == IDM_SEARCH_FINDPREV &&
+ (_options._searchType == FindRegex) &&
+ !nppParamInst.regexBackward4PowerUser()))
{
return FALSE;
}
@@ -1881,6 +1884,8 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
// this can only happen when shift-key was pressed
// regex upward search is disabled
// turn user action into a no-action step
+
+ regexBackwardMsgBox();
}
else
{
@@ -3590,6 +3595,8 @@ void FindReplaceDlg::findAllIn(InWhat op)
//enable "Search Results Window" under Search Menu
::EnableMenuItem(::GetMenu(_hParent), IDM_FOCUS_ON_FOUND_RESULTS, MF_ENABLED | MF_BYCOMMAND);
+ ::EnableMenuItem(::GetMenu(_hParent), IDM_SEARCH_GOTONEXTFOUND, MF_ENABLED | MF_BYCOMMAND);
+ ::EnableMenuItem(::GetMenu(_hParent), IDM_SEARCH_GOTOPREVFOUND, MF_ENABLED | MF_BYCOMMAND);
}
::SendMessage(_pFinder->getHSelf(), WM_SIZE, 0, 0);
@@ -3754,6 +3761,38 @@ Finder* FindReplaceDlg::getFinderFrom(HWND hwnd)
return nullptr;
}
+int FindReplaceDlg::regexBackwardMsgBox()
+{
+ NppParameters& nppParam = NppParameters::getInstance();
+
+ const int msgboxID = nppParam.getNativeLangSpeaker()->messageBox("FindRegexBackwardDisabled",
+ (*_ppEditView)->getHParent(),
+ L"By default, backward regex searching is disabled due to potentially unexpected results. " \
+ L"To perform a backward search, open the Find dialog and select either normal or extended search mode instead of regular expression.\r\n" \
+ L"Press the OK button to open the Find dialog or set focus on it.\r\n" \
+ L"\r\n" \
+ L"If you require the backward regex searching feature, consult the user manual for instructions on enabling it.",
+ L"Regex backward search disabled",
+ MB_OKCANCEL | MB_APPLMODAL | MB_ICONINFORMATION);
+
+ switch (msgboxID)
+ {
+ case IDOK:
+ {
+ doDialog(FIND_DLG, nppParam.getNativeLangSpeaker()->isRTL());
+ goToCenter();
+ ::SetFocus(::GetDlgItem(_hSelf, IDREGEXP));
+ break;
+ }
+
+ case IDCANCEL:
+ default:
+ break;
+ }
+
+ return msgboxID;
+}
+
void FindReplaceDlg::setSearchText(TCHAR * txt2find)
{
HWND hCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
@@ -4131,6 +4170,8 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_st
// regex upward search is disabled
// this macro step could have been recorded in an earlier version before it was not allowed, or hand-edited
// make this a no-action macro step
+
+ regexBackwardMsgBox();
}
else
{
@@ -4157,6 +4198,8 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_st
// regex upward search is disabled
// this macro step could have been recorded in an earlier version before it was not allowed, or hand-edited
// make this a no-action macro step
+
+ regexBackwardMsgBox();
}
else
{
@@ -4173,6 +4216,8 @@ void FindReplaceDlg::execSavedCommand(int cmd, uptr_t intValue, const generic_st
// regex upward search is disabled
// this macro step could have been recorded in an earlier version before it was disabled, or hand-edited
// make this a no-action macro step
+
+ regexBackwardMsgBox();
}
else
{
@@ -4517,6 +4562,9 @@ void FindReplaceDlg::doDialog(DIALOG_TYPE whichType, bool isRTL, bool toShow)
{
_isRTL = isRTL;
create(IDD_FIND_REPLACE_DLG, isRTL, true, toShow);
+
+ ::EnableMenuItem(::GetMenu(_hParent), IDM_SEARCH_FINDNEXT, MF_BYCOMMAND | MF_ENABLED);
+ ::EnableMenuItem(::GetMenu(_hParent), IDM_SEARCH_FINDPREV, MF_BYCOMMAND | MF_ENABLED);
}
if (whichType == FINDINFILES_DLG)
diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h
index d52dab076..79ae97283 100644
--- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h
+++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h
@@ -399,6 +399,8 @@ public :
DIALOG_TYPE getCurrentStatus() {return _currentStatus;};
Finder* getFinderFrom(HWND hwnd);
+ int regexBackwardMsgBox();
+
protected :
void resizeDialogElements();
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;