Skip to content

Commit

Permalink
now findFileNameIndexInNppOpenFileNames checks the current file first
Browse files Browse the repository at this point in the history
  • Loading branch information
d0vgan committed Jan 20, 2024
1 parent 97985ca commit 6b466f8
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions NppExec/src/NppExec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2580,19 +2580,7 @@ char* CNppExec::convertSciText(char* pSciText, int nTextLen, int nSciCodePage, e

int CNppExec::findFileNameIndexInNppOpenFileNames(const tstr& fileName, bool bGetOpenFileNames, int nView )
{
if (bGetOpenFileNames)
{
if (nView == PRIMARY_VIEW || nView == SECOND_VIEW)
{
npp_nbFiles = nppGetOpenFileNamesInView(nView);
}
else
nppGetOpenFileNames();
}

tstr S;
tstr S1 = NppExecHelpers::NormalizePath(fileName);

int nFileLevel = 0;
bool bFullPath = NppExecHelpers::IsFullPath(S1);
if (!bFullPath)
Expand All @@ -2606,6 +2594,38 @@ int CNppExec::findFileNameIndexInNppOpenFileNames(const tstr& fileName, bool bGe

NppExecHelpers::StrUpper(S1);

if (!bFullPath)
{
// checking the current (active) file first
tstr filePath;
filePath.Reserve(FILEPATH_BUFSIZE);
SendNppMsg(NPPM_GETFULLCURRENTPATH, (WPARAM) (filePath.GetMemSize() - 1), (LPARAM) filePath.data());
filePath.CalculateLength();
if (filePath.length() > S1.length())
{
if (filePath.GetAt(filePath.length() - S1.length() - 1) == _T('\\'))
{
NppExecHelpers::StrUpper(filePath);
if (filePath.EndsWith(S1))
{
S1 = filePath;
bFullPath = true;
}
}
}
}

if (bGetOpenFileNames)
{
if (nView == PRIMARY_VIEW || nView == SECOND_VIEW)
{
npp_nbFiles = nppGetOpenFileNamesInView(nView);
}
else
nppGetOpenFileNames();
}

tstr S;
int iPartialMatch1 = -1;
int iFind1 = -1;
for (int i = 0; i < npp_nbFiles; ++i)
Expand Down

0 comments on commit 6b466f8

Please sign in to comment.