Skip to content

Commit 02d29e0

Browse files
committed
improve multiline text mode Research/Replace
fix #460
1 parent 1d70114 commit 02d29e0

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

src/SearchDlg.cpp

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,41 +1774,12 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
17741774
int uID = (id == IDC_EDITMULTILINE1 ? IDC_SEARCHTEXT : IDC_REPLACETEXT);
17751775
auto buf = GetDlgItemText(static_cast<int>(uID));
17761776
std::wstring ctrlText = buf.get();
1777-
1778-
// replace all \r\n strings with real CRLFs
1779-
try
1780-
{
1781-
int ft = boost::regex::normal;
1782-
boost::wregex expression = (id == IDC_EDITMULTILINE1
1783-
? boost::wregex(L"\\(\\?:\\\\n\\|\\\\r\\\\n\\|\\\\n\\\\r\\)", ft)
1784-
: boost::wregex(L"\\\\r\\\\n", ft));
1785-
boost::match_flag_type rFlags = boost::match_default | boost::format_all;
1786-
ctrlText = regex_replace(ctrlText, expression, L"\\r\\n", rFlags);
1787-
}
1788-
catch (const std::exception&)
1789-
{
1790-
}
17911777
CMultiLineEditDlg editDlg(*this);
17921778
editDlg.SetString(ctrlText);
17931779

17941780
if (editDlg.DoModal(hResource, IDD_MULTILINEEDIT, *this) == IDOK)
17951781
{
17961782
std::wstring text = editDlg.GetSearchString();
1797-
// replace all CRLFs with \r\n strings (literal)
1798-
try
1799-
{
1800-
int ft = boost::regex::normal;
1801-
boost::wregex expression = boost::wregex(L"\\r\\n", ft);
1802-
boost::match_flag_type rFlags = boost::match_default | boost::format_all;
1803-
if (id == IDC_EDITMULTILINE1)
1804-
text = regex_replace(text, expression, L"\\(\\?:\\\\n|\\\\r\\\\n|\\\\n\\\\r\\)", rFlags);
1805-
else
1806-
text = regex_replace(text, expression, L"\\\\r\\\\n", rFlags);
1807-
}
1808-
catch (const std::exception&)
1809-
{
1810-
}
1811-
18121783
SetDlgItemText(*this, static_cast<int>(uID), text.c_str());
18131784
}
18141785
::SetFocus(GetDlgItem(*this, uID));
@@ -3441,6 +3412,7 @@ DWORD CSearchDlg::SearchThread()
34413412
if (!m_searchString.empty())
34423413
{
34433414
escapeForRegexEx(m_searchString, 0);
3415+
SearchReplace(m_searchString, L"\\r\\n", L"\\(\\?:\\\\n|\\\\r|\\\\r\\\\n\\)"); // multi-line
34443416
}
34453417
if (m_bReplace && !m_replaceString.empty())
34463418
{

0 commit comments

Comments
 (0)