From d36ea6124ab6bd4737269edfd6aefa4384e2af51 Mon Sep 17 00:00:00 2001 From: Scott Sumner <30118311+sasumner@users.noreply.github.com> Date: Fri, 20 Mar 2020 15:21:37 -0400 Subject: [PATCH] Editing tab closure activates MRU tab instead of rightmost tab, if MRU behaviour enabled MRU = Most Recently Used/Active Thanks to gstavi's patch: https://github.com/gstavi/npp/blob/master/patch/0005-Use-MRU-when-choosing-new-file-to-activate-after-clo.patch Close #885, close #8059 --- PowerEditor/src/Notepad_plus.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index c154031b5..4b6671415 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -3578,6 +3578,21 @@ bool Notepad_plus::removeBufferFromView(BufferID id, int whichOne) { toActivate = active; //activate the 'active' index. Since we remove the tab first, the indices shift (on the right side) } + if (NppParameters::getInstance().getNppGUI()._styleMRU) + { + // After closing a file choose the file to activate based on MRU list and not just last file in the list. + TaskListInfo taskListInfo; + ::SendMessage(_pPublicInterface->getHSelf(), WM_GETTASKLISTINFO, (WPARAM)&taskListInfo, 0); + size_t i, n = taskListInfo._tlfsLst.size(); + for (i = 0; i < n; i++) + { + TaskLstFnStatus& F = taskListInfo._tlfsLst[i]; + if (F._iView != whichOne || F._bufID == (void*)id) + continue; + toActivate = F._docIndex >= active ? F._docIndex - 1 : F._docIndex; + break; + } + } tabToClose->deletItemAt((size_t)index); //delete first _isFolding = true; // So we can ignore events while folding is taking place activateBuffer(tabToClose->getBufferByIndex(toActivate), whichOne); //then activate. The prevent jumpy tab behaviour