diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index d6f6d6a13..2a20a4d7c 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -2789,6 +2789,10 @@ void Notepad_plus::command(int id) case IDM_LANG_USER : { setLanguage(menuID2LangType(id)); + // Manually set language, don't change language even file extension changes. + Buffer *buffer = _pEditView->getCurrentBuffer(); + buffer->langHasBeenSetFromMenu(); + if (_pDocMap) { _pDocMap->setSyntaxHiliting(); diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 2935527d4..7fee34d97 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -205,7 +205,8 @@ void Buffer::setFileName(const TCHAR *fn, LangType defaultLang) } updateTimeStamp(); - if (newLang != _lang || _lang == L_USER) + + if (!_hasLangBeenSetFromMenu && (newLang != _lang || _lang == L_USER)) { _lang = newLang; doNotify(BufferChangeFilename | BufferChangeLanguage | BufferChangeTimestamp); diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index 3568e03f8..daa81b93d 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -351,6 +351,8 @@ public: void setMapPosition(const MapPosition & mapPosition) { _mapPosition = mapPosition; }; MapPosition getMapPosition() const { return _mapPosition; }; + void langHasBeenSetFromMenu() { _hasLangBeenSetFromMenu = true; }; + private: int indexOfReference(const ScintillaEditView * identifier) const; @@ -408,5 +410,7 @@ private: HANDLE _eventHandle = nullptr; bool _isMonitoringOn = false; + bool _hasLangBeenSetFromMenu = false; + MapPosition _mapPosition; }; \ No newline at end of file