From d7b0eb9ebf255676d0cfedab9d2eb79f8e253836 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Thu, 26 Nov 2015 09:25:09 +0100 Subject: [PATCH] Enhance language detection while "Save as" By using detectLanguageFromTextBegining function --- PowerEditor/src/ScitillaComponent/Buffer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 3a1bd750..4f606430 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -1083,6 +1083,9 @@ bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy, g if (lengthDoc == 0) items_written = 1; } + + // check the language du fichier + LangType language = detectLanguageFromTextBegining((unsigned char *)buf, lengthDoc); UnicodeConvertor.fclose(); @@ -1122,12 +1125,11 @@ bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy, g return true; //all done } - buffer->setFileName(fullpath); + buffer->setFileName(fullpath, language); buffer->setDirty(false); buffer->setStatus(DOC_REGULAR); buffer->checkFileState(); _pscratchTilla->execute(SCI_SETSAVEPOINT); - //_pscratchTilla->markSavedLines(); _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault); generic_string backupFilePath = buffer->getBackupFileName();