Fix regression "Open Selected PathName(s)" command not working with Ctrl-A

The regression is introduced by:
467182602a

The solution is from:
https://github.com/notepad-plus-plus/notepad-plus-plus/issues/15960#issuecomment-2553746218

Fix #15960
This commit is contained in:
Don Ho 2024-12-21 03:53:45 +01:00
parent 0447dc8988
commit 50c2c3a74a
1 changed files with 18 additions and 15 deletions

View File

@ -691,7 +691,6 @@ void Finder::deleteResult()
vector<wstring> Finder::getResultFilePaths(bool onlyInSelectedText) const
{
std::vector<wstring> paths;
size_t fromLine = 0, toLine = 0;
if (onlyInSelectedText)
@ -705,29 +704,32 @@ vector<wstring> Finder::getResultFilePaths(bool onlyInSelectedText) const
toLine = _scintView.execute(SCI_GETLINECOUNT) - 1;
}
size_t len = _pMainFoundInfos->size(); // First, get the number of elements in the container
size_t len = _pMainFoundInfos->size();
vector<wstring> paths;
for (size_t line = fromLine; line <= toLine; ++line)
{
bool found = false; // Was it found?
const int lineFoldLevel = _scintView.execute(SCI_GETFOLDLEVEL, line) & SC_FOLDLEVELNUMBERMASK;
if (lineFoldLevel == fileHeaderLevel)
{
line++; // Move to the next line
if (line < len)
found = true; // Found it
}
else if (lineFoldLevel == resultLevel)
{
if (line < len)
found = true; // Found it
// fileHeaderLevel lines don't have path info; have to look into the NEXT line for it,
// but only need to do something special here if we are on the LAST line of the selection
if (line == toLine)
{
++line;
}
}
if (found)
if (line < len)
{
wstring& path = (*_pMainFoundInfos)[line]._fullPath;
if (std::find(paths.begin(), paths.end(), path) == paths.end())
wstring& path2add = (*_pMainFoundInfos)[line]._fullPath;
if (!path2add.empty())
{
paths.push_back(path);
// make sure that path is not already in
if (std::find(paths.begin(), paths.end(), path2add) == paths.end())
{
paths.push_back(path2add);
}
}
}
}
@ -735,6 +737,7 @@ vector<wstring> Finder::getResultFilePaths(bool onlyInSelectedText) const
return paths;
}
bool Finder::canFind(const wchar_t *fileName, size_t lineNumber, size_t* indexToStartFrom) const
{
size_t len = _pMainFoundInfos->size();