Skip to content

Commit

Permalink
Fix regression "Open Selected PathName(s)" command not working with C…
Browse files Browse the repository at this point in the history
…trl-A

The regression is introduced by:
notepad-plus-plus@4671826

The solution is from:
notepad-plus-plus#15960 (comment)

Fix notepad-plus-plus#15960
  • Loading branch information
donho committed Dec 21, 2024
1 parent 0447dc8 commit 50c2c3a
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -705,36 +704,40 @@ 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);
}
}
}
}

return paths;
}


bool Finder::canFind(const wchar_t *fileName, size_t lineNumber, size_t* indexToStartFrom) const
{
size_t len = _pMainFoundInfos->size();
Expand Down

0 comments on commit 50c2c3a

Please sign in to comment.