Fix language detected from content not applied if default language is set

Properly handle missing file extensions in `Buffer::setFileName`

Before 6263ce5, the user-preferred default language would apply to
files with no extension, but got overwritten by `L_TEXT` when the
extension was present *but unknown*.

This is why the `buf->_lang == L_TEXT` condition failed *only for
buffers with _no_ extension*.

Fix #11504, close #12286
This commit is contained in:
Robert Di Pardo 2022-10-04 18:35:05 -04:00 committed by Don Ho
parent af0bc2e113
commit a610387fb4
1 changed files with 2 additions and 0 deletions

View File

@ -211,6 +211,8 @@ void Buffer::setFileName(const TCHAR *fn, LangType defaultLang)
newLang = nppParamInst.getLangFromExt(ext);
}
}
else if (!isUntitled()) // existing file with no extension
newLang = L_TEXT;
if (newLang == defaultLang || newLang == L_TEXT) //language can probably be refined
{