Fix renamed new tab incorrect behaviour
Double-clicking on a "find all in current document" result in a renamed new tab get a prompt to create it.
This commit is contained in:
parent
6580255a2b
commit
a2e9421669
@ -160,23 +160,24 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
|
|||||||
generic_string fileName2Find;
|
generic_string fileName2Find;
|
||||||
generic_string gs_fileName{ fileName };
|
generic_string gs_fileName{ fileName };
|
||||||
|
|
||||||
// The following code is useful while running commands "Find in current doc" & "Find in opened docs" and
|
|
||||||
// if the occurrence is found in untitled documents and user double-clicks the found entries of untitled documents.
|
|
||||||
// "fileName" is "new N"
|
|
||||||
size_t res = gs_fileName.find_first_of(UNTITLED_STR);
|
|
||||||
if (res != string::npos && res == 0)
|
|
||||||
{
|
|
||||||
fileName2Find = fileName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fileName2Find = longFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we found the document with fileName2Find, then we don't open the existing doc.
|
// "fileName" could be:
|
||||||
// we return the found buffer ID instead.
|
// 1. full file path to open or create
|
||||||
BufferID test = MainFileManager->getBufferFromName(fileName2Find.c_str());
|
// 2. "new N" or whatever renamed from "new N" to switch to (if user double-clicks the found entries of untitled documents, which is the results of running commands "Find in current doc" & "Find in opened docs")
|
||||||
if (test != BUFFER_INVALID && !isSnapshotMode)
|
// 3. a file name with relative path to open or create
|
||||||
|
|
||||||
|
// Search case 1 & 2 firstly
|
||||||
|
BufferID foundBufID = MainFileManager->getBufferFromName(fileName.c_str());
|
||||||
|
|
||||||
|
if (foundBufID == BUFFER_INVALID)
|
||||||
|
fileName2Find = longFileName;
|
||||||
|
|
||||||
|
// if case 1 & 2 not found, search case 3
|
||||||
|
if (foundBufID == BUFFER_INVALID)
|
||||||
|
foundBufID = MainFileManager->getBufferFromName(fileName2Find.c_str());
|
||||||
|
|
||||||
|
// If we found the document, then we don't open the existing doc. We return the found buffer ID instead.
|
||||||
|
if (foundBufID != BUFFER_INVALID && !isSnapshotMode)
|
||||||
{
|
{
|
||||||
if (_pTrayIco)
|
if (_pTrayIco)
|
||||||
{
|
{
|
||||||
@ -188,7 +189,7 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
|
|||||||
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
|
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return test;
|
return foundBufID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFileSession(longFileName) && PathFileExists(longFileName))
|
if (isFileSession(longFileName) && PathFileExists(longFileName))
|
||||||
|
Loading…
Reference in New Issue
Block a user