mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-26 23:34:44 +02:00
Fix wrong replace all while 2nd time replace in selection
Prevent search from running with unintended "In selection" parameter. Fix #14897, fix #14624, fix #15992, close #15995
This commit is contained in:
parent
a6103d5de7
commit
4b637b4fc8
@ -1514,7 +1514,7 @@ Do you want to continue?"/>
|
||||
please give another one."/>
|
||||
<UDLRemoveCurrentLang title="Remove the current language" message="Are you sure?"/>
|
||||
<SCMapperDoDeleteOrNot title="Are you sure?" message="Are you sure you want to delete this shortcut?"/>
|
||||
<FindCharRangeValueError title="Range Value problem" message="You should type between 0 and 255."/>
|
||||
<FindCharRangeValueError title="Range Value problem" message="You should type between 0 and 255."/> <!-- HowToReproduce: Search menu, then Find characters in range, select Custom range, enter 999 in either edit box, press Find. -->
|
||||
<OpenInAdminMode title="Save failed" message="The file cannot be saved and it may be protected.
|
||||
Do you want to launch Notepad++ in Administrator mode?"/>
|
||||
<OpenInAdminModeWithoutCloseCurrent title="Save failed" message="The file cannot be saved and it may be protected.
|
||||
@ -1555,6 +1555,8 @@ Press the OK button to open the Find dialog or set focus on it.
|
||||
|
||||
If you require the backward regex searching feature, consult the user manual for instructions on enabling it."/>
|
||||
<PrintError title="0" message="Cannot start printer document."/><!-- Use title="0" to use Windows OS default translated "Error" title. -->
|
||||
<FindAutoChangeOfInSelectionWarning title="Search warning" message="The "In selection" checkbox state has been automatically modified.
|
||||
Please verify the search condition before performing the action."/> <!-- HowToReproduce: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14897#issuecomment-2564316224 -->
|
||||
</MessageBox>
|
||||
<ClipboardHistory>
|
||||
<PanelTitle name="Clipboard History"/>
|
||||
|
@ -1512,7 +1512,7 @@ Do you want to continue?"/>
|
||||
please give another one."/>
|
||||
<UDLRemoveCurrentLang title="Remove the current language" message="Are you sure?"/>
|
||||
<SCMapperDoDeleteOrNot title="Are you sure?" message="Are you sure you want to delete this shortcut?"/>
|
||||
<FindCharRangeValueError title="Range Value problem" message="You should type between 0 and 255."/>
|
||||
<FindCharRangeValueError title="Range Value problem" message="You should type between 0 and 255."/> <!-- HowToReproduce: Search menu, then Find characters in range, select Custom range, enter 999 in either edit box, press Find. -->
|
||||
<OpenInAdminMode title="Save failed" message="The file cannot be saved and it may be protected.
|
||||
Do you want to launch Notepad++ in Administrator mode?"/>
|
||||
<OpenInAdminModeWithoutCloseCurrent title="Save failed" message="The file cannot be saved and it may be protected.
|
||||
@ -1553,6 +1553,8 @@ Press the OK button to open the Find dialog or set focus on it.
|
||||
|
||||
If you require the backward regex searching feature, consult the user manual for instructions on enabling it."/>
|
||||
<PrintError title="0" message="Cannot start printer document."/><!-- Use title="0" to use Windows OS default translated "Error" title. -->
|
||||
<FindAutoChangeOfInSelectionWarning title="Search warning" message="The "In selection" checkbox state has been automatically modified.
|
||||
Please verify the search condition before performing the action."/> <!-- HowToReproduce: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14897#issuecomment-2564316224 -->
|
||||
</MessageBox>
|
||||
<ClipboardHistory>
|
||||
<PanelTitle name="Clipboard History"/>
|
||||
|
@ -1692,6 +1692,8 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
|
||||
case WM_ACTIVATE :
|
||||
{
|
||||
bool isInSelectionAutoChange = false;
|
||||
|
||||
if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE)
|
||||
{
|
||||
Sci_CharacterRangeFull cr = (*_ppEditView)->getSelection();
|
||||
@ -1709,6 +1711,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
enableFindDlgItem(IDC_IN_SELECTION_CHECK, inSelEnabled);
|
||||
|
||||
bool inSelChecked = isCheckedOrNot(IDC_IN_SELECTION_CHECK);
|
||||
bool origInSelChecked = inSelChecked;
|
||||
|
||||
const NppGUI& nppGui = (NppParameters::getInstance()).getNppGUI();
|
||||
if (nppGui._inSelectionAutocheckThreshold != 0)
|
||||
@ -1720,6 +1723,29 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
setChecked(IDC_IN_SELECTION_CHECK, inSelChecked);
|
||||
}
|
||||
|
||||
/*
|
||||
In the scenario where the user clicks the action button (Count,
|
||||
Find All in Current Document, Replace All, Mark All, or Clear All marks)
|
||||
without activating the Find/Replace dialog, the "In Selection" checkbox could
|
||||
be auto-changed after the button click. To prevent the search from running with
|
||||
this unintended state, the search message has been removed from the queue.
|
||||
Then, launch a message box to alert the user that the search didn't run and
|
||||
they need to verify the settings.
|
||||
*/
|
||||
if (inSelChecked != origInSelChecked)
|
||||
{
|
||||
const std::vector<int> inSelActionIds = { IDCCOUNTALL, IDC_FINDALL_CURRENTFILE, IDREPLACEALL, IDCMARKALL, IDC_CLEAR_ALL };
|
||||
for (const auto& id : inSelActionIds)
|
||||
{
|
||||
MSG msg;
|
||||
if (PeekMessage(&msg, ::GetDlgItem(_hSelf, id), 0, 0, PM_REMOVE))
|
||||
{
|
||||
isInSelectionAutoChange = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_options._isInSelection = inSelEnabled && inSelChecked;
|
||||
}
|
||||
|
||||
@ -1746,7 +1772,21 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
{
|
||||
enableFindDlgItem(IDREDOTMATCHNL, false);
|
||||
}
|
||||
|
||||
enableProjectCheckmarks();
|
||||
|
||||
if (isInSelectionAutoChange)
|
||||
{
|
||||
NppParameters& nppParamInst = NppParameters::getInstance();
|
||||
(nppParamInst.getNativeLangSpeaker())->messageBox(
|
||||
"FindAutoChangeOfInSelectionWarning",
|
||||
_hSelf,
|
||||
L"The \"In selection\" checkbox state has been automatically modified.\r\n"
|
||||
L"Please verify the search condition before performing the action.",
|
||||
L"Search warning",
|
||||
MB_OK | MB_APPLMODAL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user