diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index aec0f0676..d97eaf3a0 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -20,6 +20,7 @@ #include "ScintillaEditView.h" #include "Notepad_plus_msgs.h" #include "localization.h" +#include "Common.h" #include "Utf8.h" using namespace std; @@ -2440,6 +2441,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl findAllFileNameAdded = true; } + auto totalLineNumber = pEditView->execute(SCI_GETLINECOUNT); auto lineNumber = pEditView->execute(SCI_LINEFROMPOSITION, targetStart); intptr_t lend = pEditView->execute(SCI_GETLINEENDPOSITION, lineNumber); intptr_t lstart = pEditView->execute(SCI_POSITIONFROMLINE, lineNumber); @@ -2461,7 +2463,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl SearchResultMarking srm; srm._start = static_cast(start_mark); srm._end = static_cast(end_mark); - _pFinder->add(FoundInfo(targetStart, targetEnd, lineNumber + 1, pFileName), srm, line.c_str()); + _pFinder->add(FoundInfo(targetStart, targetEnd, lineNumber + 1, pFileName), srm, line.c_str(), totalLineNumber); break; } @@ -2473,6 +2475,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl const TCHAR *pFileName = pFindersInfo->_pFileName ? pFindersInfo->_pFileName : TEXT(""); + auto totalLineNumber = pEditView->execute(SCI_GETLINECOUNT); auto lineNumber = pEditView->execute(SCI_LINEFROMPOSITION, targetStart); intptr_t lend = pEditView->execute(SCI_GETLINEENDPOSITION, lineNumber); intptr_t lstart = pEditView->execute(SCI_POSITIONFROMLINE, lineNumber); @@ -2502,7 +2505,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl pFindersInfo->_pDestFinder->addFileNameTitle(pFileName); findAllFileNameAdded = true; } - pFindersInfo->_pDestFinder->add(FoundInfo(targetStart, targetEnd, lineNumber + 1, pFileName), srm, line.c_str()); + pFindersInfo->_pDestFinder->add(FoundInfo(targetStart, targetEnd, lineNumber + 1, pFileName), srm, line.c_str(), totalLineNumber); } break; } @@ -4082,7 +4085,7 @@ void Finder::addSearchHitCount(int count, int countSearched, bool isMatchLines, setFinderReadOnly(true); } -void Finder::add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline) +void Finder::add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline, size_t totalLineNumber) { _pMainFoundInfos->push_back(fi); @@ -4090,7 +4093,13 @@ void Finder::add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline) str += _prefixLineStr; str += TEXT(" "); - str += std::to_wstring(fi._lineNumber); + size_t totalLineNumberDigit = static_cast(nbDigitsFromNbLines(totalLineNumber) + 1); + size_t currentLineNumberDigit = static_cast(nbDigitsFromNbLines(fi._lineNumber) + 1); + + generic_string lineNumberStr = TEXT(""); + lineNumberStr.append(totalLineNumberDigit - currentLineNumberDigit, ' '); + lineNumberStr.append(std::to_wstring(fi._lineNumber)); + str += lineNumberStr; str += TEXT(": "); mi._start += str.length(); mi._end += str.length(); diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h index f0d4b48fc..199b78e41 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h @@ -119,7 +119,7 @@ public: void addFileNameTitle(const TCHAR * fileName); void addFileHitCount(int count); void addSearchHitCount(int count, int countSearched, bool isMatchLines, bool searchedEntireNotSelection); - void add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline); + void add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline, size_t totalLineNumber); void setFinderStyle(); void removeAll(); void openAll();