From a610387fb40411f992f1fea38c9e7eaa7cf5c8cc Mon Sep 17 00:00:00 2001 From: Robert Di Pardo <59004801+rdipardo@users.noreply.github.com> Date: Tue, 4 Oct 2022 18:35:05 -0400 Subject: [PATCH] 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 --- PowerEditor/src/ScintillaComponent/Buffer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 1a3d00da6..241443aad 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -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 {