Fix incorrect message on double click on search result regression

This regression was inserted by commit c0be50494c (PR #11107).

Fix #11215, Fix #11106
This commit is contained in:
Don Ho 2022-02-16 17:58:08 +01:00
parent 5c02505998
commit 51b1c9377c
2 changed files with 13 additions and 12 deletions

View File

@ -505,7 +505,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_RELOADFILE:
{
BufferID id = MainFileManager.getBufferFromName(reinterpret_cast<const TCHAR *>(lParam));
TCHAR longNameFullpath[MAX_PATH];
const TCHAR* pFilePath = reinterpret_cast<const TCHAR*>(lParam);
wcscpy_s(longNameFullpath, MAX_PATH, pFilePath);
if (_tcschr(longNameFullpath, '~'))
{
::GetLongPathName(longNameFullpath, longNameFullpath, MAX_PATH);
}
BufferID id = MainFileManager.getBufferFromName(longNameFullpath);
if (id != BUFFER_INVALID)
doReload(id, wParam != 0);
break;

View File

@ -1621,20 +1621,13 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil
BufferID FileManager::getBufferFromName(const TCHAR* name)
{
TCHAR fullpath[MAX_PATH];
::GetFullPathName(name, MAX_PATH, fullpath, NULL);
if (_tcschr(fullpath, '~'))
for (auto buf : _buffers)
{
::GetLongPathName(fullpath, fullpath, MAX_PATH);
}
for (size_t i = 0; i < _buffers.size(); i++)
{
if (OrdinalIgnoreCaseCompareStrings(fullpath, _buffers.at(i)->getFullPathName()) == 0)
if (OrdinalIgnoreCaseCompareStrings(name, buf->getFullPathName()) == 0)
{
if (_buffers.at(i)->_referees[0]->isVisible())
if (buf->_referees[0]->isVisible())
{
return _buffers.at(i)->getID();
return buf->getID();
}
}
}