mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 07:44:24 +02:00
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:
parent
311c4e58cf
commit
f3abc30c7a
@ -209,7 +209,6 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool globbing = wcsrchr(longFileName, TCHAR('*')) || wcsrchr(longFileName, TCHAR('?'));
|
bool globbing = wcsrchr(longFileName, TCHAR('*')) || wcsrchr(longFileName, TCHAR('?'));
|
||||||
bool isOpenningNewEmptyFile = false;
|
|
||||||
|
|
||||||
if (!isSnapshotMode) // if not backup mode, or backupfile path is invalid
|
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)
|
if (res)
|
||||||
{
|
{
|
||||||
isCreateFileSuccessful = true;
|
isCreateFileSuccessful = true;
|
||||||
isOpenningNewEmptyFile = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -300,16 +298,6 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
|
|||||||
if (isReadOnly)
|
if (isReadOnly)
|
||||||
buf->setUserReadOnly(true);
|
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
|
// Notify plugins that current file is about to open
|
||||||
scnN.nmhdr.code = NPPN_FILEBEFOREOPEN;
|
scnN.nmhdr.code = NPPN_FILEBEFOREOPEN;
|
||||||
scnN.nmhdr.idFrom = (uptr_t)buffer;
|
scnN.nmhdr.idFrom = (uptr_t)buffer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user