Skip to content

Commit

Permalink
[BUG_FIXED] Fix the initial document encoding is not set by "New Docu…
Browse files Browse the repository at this point in the history
…ment Settings".

- Notepad-plus svn trunk @ 707
  • Loading branch information
donho committed Nov 17, 2010
1 parent 249194d commit 86338f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
14 changes: 0 additions & 14 deletions PowerEditor/src/NppIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,20 +843,6 @@ void Notepad_plus::fileNew()
BufferID newBufID = MainFileManager->newEmptyDocument();
loadBufferIntoView(newBufID, currentView(), true); //true, because we want multiple new files if possible
activateBuffer(newBufID, currentView());

NppParameters *pNppParam = NppParameters::getInstance();
NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI();
NewDocDefaultSettings & ndds = (NewDocDefaultSettings &)nppGUI.getNewDocDefaultSettings();
if (ndds._codepage != -1)
{
EncodingMapper *em = EncodingMapper::getInstance();
int cmdID = em->getIndexFromEncoding(ndds._codepage);
if (cmdID != -1)
{
cmdID += IDM_FORMAT_ENCODE;
::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, cmdID, 0);
}
}
}

bool Notepad_plus::isFileSession(const TCHAR * filename) {
Expand Down
12 changes: 10 additions & 2 deletions PowerEditor/src/ScitillaComponent/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "Parameters.h"
#include "Notepad_plus.h"
#include "ScintillaEditView.h"
#include "EncodingMapper.h"

FileManager * FileManager::_pSelf = new FileManager();

Expand All @@ -42,6 +43,9 @@ Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus
const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
_format = ndds._format;
_unicodeMode = ndds._encoding;
_encoding = ndds._codepage;
if (_encoding != -1)
_unicodeMode = uniCookie;

_userLangExt[0] = 0;
_fullPathName[0] = 0;
Expand Down Expand Up @@ -463,6 +467,12 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin
_nrBufs++;
Buffer * buf = _buffers.at(_nrBufs - 1);

// restore the encoding (ANSI based) while opening the existing file
NppParameters *pNppParamInst = NppParameters::getInstance();
const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
buf->setUnicodeMode(ndds._encoding);
buf->setEncoding(-1);

if (encoding == -1)
{
// 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT
Expand All @@ -480,8 +490,6 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin
UniMode um = UnicodeConvertor.getEncoding();
if (um == uni7Bit)
{
NppParameters *pNppParamInst = NppParameters::getInstance();
const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings();
if (ndds._openAnsiAsUtf8)
{
um = uniCookie;
Expand Down

0 comments on commit 86338f7

Please sign in to comment.