Make Find in Files Search Result line number aligned
Fix #11119, close #11479
This commit is contained in:
parent
88ed851478
commit
b4a58429c3
|
@ -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<long>(start_mark);
|
||||
srm._end = static_cast<long>(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<size_t>(nbDigitsFromNbLines(totalLineNumber) + 1);
|
||||
size_t currentLineNumberDigit = static_cast<size_t>(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();
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue