From e975e06410eac72a0a33a54d0fb01386951ecea8 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Thu, 15 May 2014 16:43:56 +0000 Subject: [PATCH] [BUG_FIXED] Fix session snapshot SaveAll bug. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1238 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/ScitillaComponent/Buffer.cpp | 32 +++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index c1bcc23a..6217c86e 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -976,10 +976,21 @@ bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy, g if (isCopy) { _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault); - + + /* for saveAs it's not necessary since this action is for the "current" directory, so we let manage in SAVEPOINTREACHED event + generic_string backupFilePath = buffer->getBackupFileName(); + if (backupFilePath != TEXT("")) + { + // delete backup file + generic_string file2Delete = buffer->getBackupFileName(); + buffer->setBackupFileName(TEXT("")); + ::DeleteFile(file2Delete.c_str()); + } + */ + // set to signaled state ::SetEvent(writeEvent); - ::CloseHandle(writeEvent); + ::CloseHandle(writeEvent); return true; //all done } @@ -991,6 +1002,15 @@ bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy, g //_pscratchTilla->markSavedLines(); _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault); + generic_string backupFilePath = buffer->getBackupFileName(); + if (backupFilePath != TEXT("")) + { + // delete backup file + generic_string file2Delete = buffer->getBackupFileName(); + buffer->setBackupFileName(TEXT("")); + ::DeleteFile(file2Delete.c_str()); + } + // set to signaled state ::SetEvent(writeEvent); ::CloseHandle(writeEvent); @@ -1130,9 +1150,9 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea _pscratchTilla->execute(SCI_SETREADONLY, false); } _pscratchTilla->execute(SCI_CLEARALL); -#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); -#endif + if (language < L_EXTERNAL) { _pscratchTilla->execute(SCI_SETLEXER, ScintillaEditView::langNames[language].lexerID); @@ -1141,11 +1161,7 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea { int id = language - L_EXTERNAL; TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name; -#ifdef UNICODE const char *pName = wmc->wchar2char(name, CP_ACP); -#else - const char *pName = name; -#endif _pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)pName); }