Add count of files searched to 'Find result' output

Close #3980, close #8154
This commit is contained in:
Scott Sumner 2020-04-21 15:47:58 -04:00 committed by Don HO
parent 85c0b3d692
commit 9f23e1aadb
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
3 changed files with 19 additions and 16 deletions

View File

@ -1680,7 +1680,7 @@ bool Notepad_plus::findInFinderFiles(FindersInfo *findInFolderInfo)
} }
progress.close(); progress.close();
findInFolderInfo->_pDestFinder->finishFilesSearch(nbTotal, findInFolderInfo->_findOption._isMatchLineNumber); findInFolderInfo->_pDestFinder->finishFilesSearch(nbTotal, int(filesCount), findInFolderInfo->_findOption._isMatchLineNumber);
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
_pEditView = pOldView; _pEditView = pOldView;
@ -1766,7 +1766,7 @@ bool Notepad_plus::findInFiles()
progress.close(); progress.close();
_findReplaceDlg.finishFilesSearch(nbTotal); _findReplaceDlg.finishFilesSearch(nbTotal, int(filesCount));
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
_pEditView = pOldView; _pEditView = pOldView;
@ -1807,7 +1807,9 @@ bool Notepad_plus::findInOpenedFiles()
} }
} }
if (_mainWindowStatus & WindowSubActive) size_t nbUniqueBuffers = _mainDocTab.nbItem();
if (_mainWindowStatus & WindowSubActive)
{ {
for (size_t i = 0, len2 = _subDocTab.nbItem(); i < len2 ; ++i) for (size_t i = 0, len2 = _subDocTab.nbItem(); i < len2 ; ++i)
{ {
@ -1822,10 +1824,11 @@ bool Notepad_plus::findInOpenedFiles()
FindersInfo findersInfo; FindersInfo findersInfo;
findersInfo._pFileName = pBuf->getFullPathName(); findersInfo._pFileName = pBuf->getFullPathName();
nbTotal += _findReplaceDlg.processAll(ProcessFindAll, FindReplaceDlg::_env, isEntireDoc, &findersInfo); nbTotal += _findReplaceDlg.processAll(ProcessFindAll, FindReplaceDlg::_env, isEntireDoc, &findersInfo);
++nbUniqueBuffers;
} }
} }
_findReplaceDlg.finishFilesSearch(nbTotal); _findReplaceDlg.finishFilesSearch(nbTotal, int(nbUniqueBuffers));
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
_pEditView = pOldView; _pEditView = pOldView;
@ -1858,7 +1861,7 @@ bool Notepad_plus::findInCurrentFile()
findersInfo._pFileName = pBuf->getFullPathName(); findersInfo._pFileName = pBuf->getFullPathName();
nbTotal += _findReplaceDlg.processAll(ProcessFindAll, FindReplaceDlg::_env, isEntireDoc, &findersInfo); nbTotal += _findReplaceDlg.processAll(ProcessFindAll, FindReplaceDlg::_env, isEntireDoc, &findersInfo);
_findReplaceDlg.finishFilesSearch(nbTotal); _findReplaceDlg.finishFilesSearch(nbTotal, 1);
_invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc); _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc);
_pEditView = pOldView; _pEditView = pOldView;

View File

@ -3144,18 +3144,18 @@ void Finder::addFileHitCount(int count)
++_nbFoundFiles; ++_nbFoundFiles;
} }
void Finder::addSearchHitCount(int count, bool isMatchLines) void Finder::addSearchHitCount(int count, int countSearched, bool isMatchLines)
{ {
const TCHAR *moreInfo = isMatchLines ? TEXT(" - Line Filter Mode: only display the filtered results") :TEXT(""); const TCHAR *moreInfo = isMatchLines ? TEXT(" - Line Filter Mode: only display the filtered results") :TEXT("");
TCHAR text[100]; TCHAR text[100];
if (count == 1 && _nbFoundFiles == 1) if (count == 1 && _nbFoundFiles == 1)
wsprintf(text, TEXT(" (1 hit in 1 file%s)"), moreInfo); wsprintf(text, TEXT(" (1 hit in 1 file of %i searched%s)"), countSearched, moreInfo);
else if (count == 1 && _nbFoundFiles != 1) else if (count == 1 && _nbFoundFiles != 1)
wsprintf(text, TEXT(" (1 hit in %i files%s)"), _nbFoundFiles, moreInfo); wsprintf(text, TEXT(" (1 hit in %i files of %i searched%s)"), _nbFoundFiles, countSearched, moreInfo);
else if (count != 1 && _nbFoundFiles == 1) else if (count != 1 && _nbFoundFiles == 1)
wsprintf(text, TEXT(" (%i hits in 1 file%s)"), count, moreInfo); wsprintf(text, TEXT(" (%i hits in 1 file of %i searched%s)"), count, countSearched, moreInfo);
else if (count != 1 && _nbFoundFiles != 1) else if (count != 1 && _nbFoundFiles != 1)
wsprintf(text, TEXT(" (%i hits in %i files%s)"), count, _nbFoundFiles, moreInfo); wsprintf(text, TEXT(" (%i hits in %i files of %i searched%s)"), count, _nbFoundFiles, countSearched, moreInfo);
setFinderReadOnly(false); setFinderReadOnly(false);
_scintView.insertGenericTextFrom(_lastSearchHeaderPos, text); _scintView.insertGenericTextFrom(_lastSearchHeaderPos, text);
setFinderReadOnly(true); setFinderReadOnly(true);
@ -3290,7 +3290,7 @@ void Finder::beginNewFilesSearch()
_scintView.collapse(searchHeaderLevel - SC_FOLDLEVELBASE, fold_collapse); _scintView.collapse(searchHeaderLevel - SC_FOLDLEVELBASE, fold_collapse);
} }
void Finder::finishFilesSearch(int count, bool isMatchLines) void Finder::finishFilesSearch(int count, int searchedCount, bool isMatchLines)
{ {
std::vector<FoundInfo>* _pOldFoundInfos; std::vector<FoundInfo>* _pOldFoundInfos;
std::vector<SearchResultMarking>* _pOldMarkings; std::vector<SearchResultMarking>* _pOldMarkings;
@ -3308,7 +3308,7 @@ void Finder::finishFilesSearch(int count, bool isMatchLines)
if (_pMainMarkings->size() > 0) if (_pMainMarkings->size() > 0)
_markingsStruct._markings = &((*_pMainMarkings)[0]); _markingsStruct._markings = &((*_pMainMarkings)[0]);
addSearchHitCount(count, isMatchLines); addSearchHitCount(count, searchedCount, isMatchLines);
_scintView.execute(SCI_SETSEL, 0, 0); _scintView.execute(SCI_SETSEL, 0, 0);
_scintView.execute(SCI_SETLEXER, SCLEX_SEARCHRESULT); _scintView.execute(SCI_SETLEXER, SCLEX_SEARCHRESULT);

View File

@ -125,14 +125,14 @@ public:
void addSearchLine(const TCHAR *searchName); void addSearchLine(const TCHAR *searchName);
void addFileNameTitle(const TCHAR * fileName); void addFileNameTitle(const TCHAR * fileName);
void addFileHitCount(int count); void addFileHitCount(int count);
void addSearchHitCount(int count, bool isMatchLines = false); void addSearchHitCount(int count, int countSearched, bool isMatchLines = false);
void add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline); void add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline);
void setFinderStyle(); void setFinderStyle();
void removeAll(); void removeAll();
void openAll(); void openAll();
void copy(); void copy();
void beginNewFilesSearch(); void beginNewFilesSearch();
void finishFilesSearch(int count, bool isMatchLines = false); void finishFilesSearch(int count, int searchedCount, bool isMatchLines = false);
void gotoNextFoundResult(int direction); void gotoNextFoundResult(int direction);
void gotoFoundLine(); void gotoFoundLine();
void deleteResult(); void deleteResult();
@ -302,9 +302,9 @@ public :
_pFinder->addSearchLine(getText2search().c_str()); _pFinder->addSearchLine(getText2search().c_str());
} }
void finishFilesSearch(int count) void finishFilesSearch(int count, int searchedCount)
{ {
_pFinder->finishFilesSearch(count); _pFinder->finishFilesSearch(count, searchedCount);
} }
void focusOnFinder() { void focusOnFinder() {