Recognize new file type via its file extension when file is created from the command line

Closes #2018, fixes #2016
This commit fixes the issue of notepad++ defaulting to 'Normal text file'
file type when creating new file form the command like:
notepad++.exe new_example_file.cpp
This commit is contained in:
Vineel Kumar Reddy Kovvuri 2016-06-27 07:34:51 +05:30 committed by Don Ho
parent 311c4e58cf
commit f3abc30c7a

View File

@ -209,7 +209,6 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
}
bool globbing = wcsrchr(longFileName, TCHAR('*')) || wcsrchr(longFileName, TCHAR('?'));
bool isOpenningNewEmptyFile = false;
if (!isSnapshotMode) // if not backup mode, or backupfile path is invalid
{
@ -229,7 +228,6 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
if (res)
{
isCreateFileSuccessful = true;
isOpenningNewEmptyFile = true;
}
else
{
@ -300,16 +298,6 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
if (isReadOnly)
buf->setUserReadOnly(true);
// if it's a new created file, then use new file default settings
if (isOpenningNewEmptyFile)
{
const NewDocDefaultSettings & ndds = (NppParameters::getInstance()->getNppGUI()).getNewDocDefaultSettings();
buf->setEncoding(ndds._codepage);
buf->setEolFormat(ndds._format);
buf->setUnicodeMode(ndds._unicodeMode);
buf->setLangType(ndds._lang);
}
// Notify plugins that current file is about to open
scnN.nmhdr.code = NPPN_FILEBEFOREOPEN;
scnN.nmhdr.idFrom = (uptr_t)buffer;