@ -601,31 +601,13 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin
Buffer * buf = _buffers . at ( _nbBufs - 1 ) ;
// restore the encoding (ANSI based) while opening the existing file
NppParameters * pNppParamInst = NppParameters : : getInstance ( ) ;
const NewDocDefaultSettings & ndds = ( pNppParamInst - > getNppGUI ( ) ) . getNewDocDefaultSettings ( ) ;
buf - > setUnicodeMode ( ndds . _unicodeMode ) ;
buf - > setEncoding ( - 1 ) ;
// if no file extension, and the language has been detected, we use the detected value
if ( ( buf - > getLangType ( ) = = L_TEXT ) & & ( detectedLang ! = L_TEXT ) )
buf - > setLangType ( detectedLang ) ;
if ( encoding = = - 1 )
{
UniMode um = UnicodeConvertor . getEncoding ( ) ;
if ( um = = uni7Bit )
um = ( ndds . _openAnsiAsUtf8 ) ? uniCookie : uni8Bit ;
buf - > setUnicodeMode ( um ) ;
}
else // encoding != -1
{
// Test if encoding is set to UTF8 w/o BOM (usually for utf8 indicator of xml or html)
buf - > setEncoding ( ( encoding = = SC_CP_UTF8 ) ? - 1 : encoding ) ;
buf - > setUnicodeMode ( uniCookie ) ;
}
buf - > setEolFormat ( bkformat ) ;
setLoadedBufferEncodingAndEol ( buf , UnicodeConvertor , encoding , bkformat ) ;
//determine buffer properties
+ + _nextBufferID ;
@ -659,14 +641,30 @@ bool FileManager::reloadBuffer(BufferID id)
buf - > _canNotify = true ;
if ( res )
{
setLoadedBufferEncodingAndEol ( buf , UnicodeConvertor , encoding , bkformat ) ;
}
return res ;
}
void FileManager : : setLoadedBufferEncodingAndEol ( Buffer * buf , const Utf8_16_Read & UnicodeConvertor , int encoding , EolType bkformat )
{
if ( encoding = = - 1 )
{
buf - > setUnicodeMode ( UnicodeConvertor . getEncoding ( ) ) ;
NppParameters * pNppParamInst = NppParameters : : getInstance ( ) ;
const NewDocDefaultSettings & ndds = ( pNppParamInst - > getNppGUI ( ) ) . getNewDocDefaultSettings ( ) ;
UniMode um = UnicodeConvertor . getEncoding ( ) ;
if ( um = = uni7Bit )
um = ( ndds . _openAnsiAsUtf8 ) ? uniCookie : uni8Bit ;
buf - > setUnicodeMode ( um ) ;
}
else
{
buf - > setEncoding ( encoding ) ;
// Test if encoding is set to UTF8 w/o BOM (usually for utf8 indicator of xml or html)
buf - > setEncoding ( ( encoding = = SC_CP_UTF8 ) ? - 1 : encoding ) ;
buf - > setUnicodeMode ( uniCookie ) ;
}
@ -674,8 +672,6 @@ bool FileManager::reloadBuffer(BufferID id)
if ( bkformat ! = EolType : : unknown )
buf - > setEolFormat ( bkformat ) ;
}
return res ;
}
bool FileManager : : reloadBufferDeferred ( BufferID id )