From 0bb88d079be9215775cf9e858b5c9b1d3e132e95 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 20 Apr 2010 19:30:50 +0000 Subject: [PATCH] [NEW_BEHAVIOUR] File detection : Switch to modified or deleted file while user is asked to reload or keep the file. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@631 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 13 +++++++++++-- PowerEditor/src/Notepad_plus.h | 5 +++++ PowerEditor/src/ScitillaComponent/Buffer.cpp | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 3625582e9..5e8be1e82 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -3926,11 +3926,19 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) { bool autoUpdate = (nppGUI._fileAutoDetection == cdAutoUpdate) || (nppGUI._fileAutoDetection == cdAutoUpdateGo2end); if (!autoUpdate || buffer->isDirty()) { + // if file updating is not silently, we switch to the file to update. + int index = _pDocTab->getIndexByBuffer(buffer->getID()); + int iView = currentView(); + if (index == -1) + iView = otherView(); + activateBuffer(buffer->getID(), iView); //activate the buffer in the first view possible + + // Then we ask user to update didDialog = true; if (doReloadOrNot(buffer->getFullPathName(), buffer->isDirty()) != IDYES) break; //abort } - //activateBuffer(buffer->getID(), iView); //activate the buffer in the first view possible + doReload(buffer->getID(), false); if (mainActive || subActive) { @@ -3944,7 +3952,8 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) { int iView = currentView(); if (index == -1) iView = otherView(); - //activateBuffer(buffer->getID(), iView); //activate the buffer in the first view possible + + activateBuffer(buffer->getID(), iView); //activate the buffer in the first view possible didDialog = true; if (doCloseOrNot(buffer->getFullPathName()) == IDNO) { diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 68d6ebf5a..c781243a5 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -182,6 +182,11 @@ public: LRESULT init(HWND hwnd); LRESULT process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); void killAllChildren(); + /* + HWND getWindowHandle() const { + return _pPublicInterface->getHSelf(); + }; + */ enum comment_mode {cm_comment, cm_uncomment, cm_toggle}; diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index f85fe9a14..5d8932d33 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -343,7 +343,7 @@ void FileManager::checkFilesystemChanges() { i = _nrBufs - 1; } - _buffers[i]->checkFileState(); //something has changed. Triggers update automatically + _buffers[i]->checkFileState(); //something has changed. Triggers update automatically } }