From 9dd5e628026273fc21a15af41d721045bb53f1a4 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 28 Oct 2014 22:26:17 +0000 Subject: [PATCH] [NEW_FEATURE] (Author: Etienne Boireau) While current file is closed the previous activated file will be activated (MRU). git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1282 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 34 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 9d5ec266..edb16e2c 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -3017,18 +3017,28 @@ bool Notepad_plus::removeBufferFromView(BufferID id, int whichOne) } else { - int toActivate = 0; - //activate next doc, otherwise prev if not possible - if (active == tabToClose->nbItem() - 1) //prev - { - toActivate = active - 1; - } - else - { - toActivate = active; //activate the 'active' index. Since we remove the tab first, the indices shift (on the right side) - } - tabToClose->deletItemAt((size_t)index); //delete first - activateBuffer(tabToClose->getBufferByIndex(toActivate), whichOne); //then activate. The prevent jumpy tab behaviour + BufferID bufferToActivate = NULL; + if (NppParameters::getInstance()->getNppGUI()._styleMRU) // If Most-Recently-Used mode: + { // Activate Most-Recently-Used doc: + TaskListInfo taskListInfo; + ::SendMessage(_pPublicInterface->getHSelf(), WM_GETTASKLISTINFO, (WPARAM)&taskListInfo, 0); + bufferToActivate = static_cast(taskListInfo._tlfsLst[1]._bufID); + } + else + { // Activate next doc, otherwise previous if not possible: + int toActivate = 0; + if (active == tabToClose->nbItem() - 1) // If last doc: + { + toActivate = active - 1; // Activate previous doc. + } + else + { + toActivate = active + 1; // Activate next doc. + } + bufferToActivate = tabToClose->getBufferByIndex(toActivate); + } + tabToClose->deletItemAt((size_t)index); //delete first + activateBuffer(bufferToActivate, whichOne); //then activate. The prevent jumpy tab behaviour } } else