From 5bacca36015056c4c1b5a3d5a21f5b524fc1158d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20J=C3=B6nsson?= Date: Fri, 24 Apr 2015 19:18:54 +0200 Subject: [PATCH 1/2] Fix ampersands in find dialog status bar. --- .../src/ScitillaComponent/FindReplaceDlg.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index f44adc079..69421fd00 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -1146,6 +1146,18 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP return FALSE; } +generic_string replaceString(generic_string subject, const generic_string& search, const generic_string& replace) +{ + size_t pos = 0; + while ((pos = subject.find(search, pos)) != std::string::npos) + { + subject.replace(pos, search.length(), replace); + pos += replace.length(); + } + return subject; +} + + // return value : // true : the text2find is found // false : the text2find is not found @@ -1275,7 +1287,8 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op if (NotIncremental == pOptions->_incrementalType) //incremental search doesnt trigger messages { generic_string msg = TEXT("Find: Can't find the text \""); - msg += txt2find; + generic_string txt2find_escaped = replaceString(txt2find, TEXT("&"), TEXT("&&")); + msg += txt2find_escaped; msg += TEXT("\""); setStatusbarMessage(msg, FSNotFound); From 930464fb8cf7ce363f4eefc0ce05fee4f7b76bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20J=C3=B6nsson?= Date: Sat, 25 Apr 2015 08:59:38 +0200 Subject: [PATCH 2/2] Cleanup after comments in pull review. --- PowerEditor/src/MISC/Common/Common.cpp | 10 ++++++++++ PowerEditor/src/MISC/Common/Common.h | 1 + .../src/ScitillaComponent/FindReplaceDlg.cpp | 15 +-------------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 25bd616c8..11db3f3be 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -707,3 +707,13 @@ generic_string stringToUpper(generic_string strToConvert) return strToConvert; } +generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace) +{ + size_t pos = 0; + while ((pos = subject.find(search, pos)) != std::string::npos) + { + subject.replace(pos, search.length(), replace); + pos += replace.length(); + } + return subject; +} \ No newline at end of file diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index 5d91111c2..5164c9524 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -187,5 +187,6 @@ generic_string PathRemoveFileSpec(generic_string & path); generic_string PathAppend(generic_string &strDest, const generic_string & str2append); COLORREF getCtrlBgColor(HWND hWnd); generic_string stringToUpper(generic_string strToConvert); +generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace); #endif //M30_IDE_COMMUN_H diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 69421fd00..2385a3ae7 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -1146,18 +1146,6 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP return FALSE; } -generic_string replaceString(generic_string subject, const generic_string& search, const generic_string& replace) -{ - size_t pos = 0; - while ((pos = subject.find(search, pos)) != std::string::npos) - { - subject.replace(pos, search.length(), replace); - pos += replace.length(); - } - return subject; -} - - // return value : // true : the text2find is found // false : the text2find is not found @@ -1287,8 +1275,7 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op if (NotIncremental == pOptions->_incrementalType) //incremental search doesnt trigger messages { generic_string msg = TEXT("Find: Can't find the text \""); - generic_string txt2find_escaped = replaceString(txt2find, TEXT("&"), TEXT("&&")); - msg += txt2find_escaped; + msg += stringReplace(txt2find, TEXT("&"), TEXT("&&")); msg += TEXT("\""); setStatusbarMessage(msg, FSNotFound);