diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 81948c429..2fc85af17 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1719,9 +1719,9 @@ Find in all files but exclude all folders log or logs recursively: - + - + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 4731f5955..a3f7ee5b2 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -1717,9 +1717,9 @@ Find in all files but exclude all folders log or logs recursively: - + - + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 722e11af5..ec7fdbfce 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2055,7 +2055,7 @@ bool Notepad_plus::findInFinderFiles(FindersInfo *findInFolderInfo) _pEditView = &_invisibleEditView; Document oldDoc = _invisibleEditView.execute(SCI_GETDOCPOINTER); - vector fileNames = findInFolderInfo->_pSourceFinder->getResultFilePaths(); + vector fileNames = findInFolderInfo->_pSourceFinder->getResultFilePaths(false); findInFolderInfo->_pDestFinder->beginNewFilesSearch(); findInFolderInfo->_pDestFinder->addSearchLine(findInFolderInfo->_findOption._str2Search.c_str()); diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index cbbc6cfe2..10f594ddf 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -682,24 +682,45 @@ void Finder::deleteResult() assert(size_t(_scintView.execute(SCI_GETLINECOUNT)) == _pMainFoundInfos->size() + 1); } -vector Finder::getResultFilePaths() const +vector Finder::getResultFilePaths(bool onlyInSelectedText) const { - vector paths; - size_t len = _pMainFoundInfos->size(); - for (size_t i = 0; i < len; ++i) + std::vector paths; + size_t fromLine = 0, toLine = 0; + + if (onlyInSelectedText) { - // make sure that path is not already in - wstring & path2add = (*_pMainFoundInfos)[i]._fullPath; - bool found = path2add.empty(); - for (size_t j = 0; j < paths.size() && !found; ++j) - { - if (paths[j] == path2add) - found = true; + const pair lineRange = _scintView.getSelectionLinesRange(); + fromLine = lineRange.first; + toLine = lineRange.second; + } + else + { + toLine = _scintView.execute(SCI_GETLINECOUNT) - 1; + } + for (size_t line = fromLine; line <= toLine; ++line) + { + const int lineFoldLevel = _scintView.execute(SCI_GETFOLDLEVEL, line) & SC_FOLDLEVELNUMBERMASK; + if (lineFoldLevel == fileHeaderLevel) + { + wstring lineStr = _scintView.getLine(line); + + // fileHeaderLevel line format examples: + // spacespaceD:\folder\file.ext (2 hits) + // spacespacenew 1 (1 hit) + const size_t startIndex = 2; // for number of leading spaces + auto endIndex = lineStr.find_last_of(L'('); + --endIndex; // adjust for space in front of ( + wstring path = lineStr.substr(startIndex, endIndex - startIndex); + + // make sure that path is not already in before adding + if (std::find(paths.begin(), paths.end(), path) == paths.end()) + { + paths.push_back(path); + } } - if (!found) - paths.push_back(path2add); } + return paths; } @@ -5350,7 +5371,7 @@ void Finder::removeAll() void Finder::openAll() { - for (auto&& path : getResultFilePaths()) + for (auto&& path : getResultFilePaths(true)) { ::SendMessage(_hParent, WM_DOOPEN, 0, reinterpret_cast(path.c_str())); } @@ -5359,7 +5380,7 @@ void Finder::openAll() void Finder::copyPathnames() { wstring toClipboard; - for (auto&& path : getResultFilePaths()) + for (auto&& path : getResultFilePaths(true)) { toClipboard += path + L"\r\n"; } @@ -5710,12 +5731,12 @@ intptr_t CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam wstring copyLines = pNativeSpeaker->getLocalizedStrFromID("finder-copy", L"Copy Selected Line(s)"); wstring copyVerbatim = pNativeSpeaker->getNativeLangMenuString(IDM_EDIT_COPY, L"Copy", true); copyVerbatim += L"\tCtrl+C"; - wstring copyPaths = pNativeSpeaker->getLocalizedStrFromID("finder-copy-paths", L"Copy Pathname(s)"); + wstring copyPaths = pNativeSpeaker->getLocalizedStrFromID("finder-copy-paths", L"Copy Selected Pathname(s)"); wstring selectAll = pNativeSpeaker->getNativeLangMenuString(IDM_EDIT_SELECTALL, L"Select all", true); selectAll += L"\tCtrl+A"; wstring clearAll = pNativeSpeaker->getLocalizedStrFromID("finder-clear-all", L"Clear all"); wstring purgeForEverySearch = pNativeSpeaker->getLocalizedStrFromID("finder-purge-for-every-search", L"Purge for every search"); - wstring openAll = pNativeSpeaker->getLocalizedStrFromID("finder-open-all", L"Open all"); + wstring openAll = pNativeSpeaker->getLocalizedStrFromID("finder-open-all", L"Open Selected Pathname(s)"); wstring wrapLongLines = pNativeSpeaker->getLocalizedStrFromID("finder-wrap-long-lines", L"Word wrap long lines"); tmp.push_back(MenuItemUnit(NPPM_INTERNAL_FINDINFINDERDLG, findInFinder)); diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h index 8428cce95..62b438cc7 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h @@ -143,7 +143,7 @@ public: void gotoNextFoundResult(int direction); std::pair gotoFoundLine(size_t nOccurrence = 0); // value 0 means this argument is not used void deleteResult(); - std::vector getResultFilePaths() const; + std::vector getResultFilePaths(bool onlyInSelectedText) const; bool canFind(const wchar_t *fileName, size_t lineNumber, size_t* indexToStartFrom) const; void setVolatiled(bool val) { _canBeVolatiled = val; }; std::wstring getHitsString(int count) const; diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index a99e61e58..cbd5ea15d 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -2801,7 +2801,7 @@ void ScintillaEditView::showCallTip(size_t startPos, const wchar_t * def) execute(SCI_CALLTIPSHOW, startPos, reinterpret_cast(defA)); } -wstring ScintillaEditView::getLine(size_t lineNumber) +wstring ScintillaEditView::getLine(size_t lineNumber) const { size_t lineLen = execute(SCI_LINELENGTH, lineNumber); const size_t bufSize = lineLen + 1; @@ -2810,7 +2810,7 @@ wstring ScintillaEditView::getLine(size_t lineNumber) return buf.get(); } -void ScintillaEditView::getLine(size_t lineNumber, wchar_t * line, size_t lineBufferLen) +void ScintillaEditView::getLine(size_t lineNumber, wchar_t * line, size_t lineBufferLen) const { // make sure the buffer length is enough to get the whole line size_t lineLen = execute(SCI_LINELENGTH, lineNumber); diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h index b1326ff90..fadc47bc6 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h @@ -476,8 +476,8 @@ public: intptr_t replaceTargetRegExMode(const wchar_t * re, intptr_t fromTargetPos = -1, intptr_t toTargetPos = -1) const; void showAutoComletion(size_t lenEntered, const wchar_t * list); void showCallTip(size_t startPos, const wchar_t * def); - std::wstring getLine(size_t lineNumber); - void getLine(size_t lineNumber, wchar_t * line, size_t lineBufferLen); + std::wstring getLine(size_t lineNumber) const; + void getLine(size_t lineNumber, wchar_t * line, size_t lineBufferLen) const; void addText(size_t length, const char *buf); void insertNewLineAboveCurrentLine();