notepad-plus-plus icon indicating copy to clipboard operation
notepad-plus-plus copied to clipboard

[Feature request] Restore tab order on startup

Open GiottoVerducci opened this issue 7 months ago • 3 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Description of the Issue

I usually have a lot of tabs opened, but work with a small subset of them on a given task, switching between the last 2 or 3 visited tabs (using CTRL-TAB). If I close Notepadd++ and reopen it, it reopens the last tab, but the order of the other tabs is lost. If I navigate using CTRL-TAB, it opens the first tab of the document list instead of what was my "previous" tab. Since I have a lot of tabs, finding the other tabs I worked with last is tiresome.

Describe the solution you'd like.

The tab order when cycling through tabs (using CTRL-TAB and SHIFT-CTRL-TAB) should be saved and restored when exiting and starting Notepad++.

Debug Information

Notepad++ v8.8.1   (64-bit)
Build time : May  3 2025 - 18:41:09
Scintilla/Lexilla included : 5.5.6/5.4.4
Boost Regex included : 1_85
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line : 
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : ON
Placeholders : OFF
Scintilla Rendering Mode : SC_TECHNOLOGY_DEFAULT (0)
Multi-instance Mode : monoInst
File Status Auto-Detection : cdEnabledNew (for current file/tab only)
Dark Mode : OFF
OS Name : Windows 10 Pro (64-bit)
OS Version : 22H2
OS Build : 19045.5854
Current ANSI codepage : 1252
Plugins : 
    mimeTools (3.1)
    NppConverter (4.6)
    NppExport (0.4)
    XMLTools (3.1.1.13)

Anything else?

No response

GiottoVerducci avatar Jun 02 '25 06:06 GiottoVerducci

Hi, Is this worth while to invest time? I mean i would like to give it a try if this is. Also can you attach a Screen shot of what you mean in this feature request?

adityabad avatar Jun 02 '25 14:06 adityabad

A screenshot would not show much.

Consider the following scenario: create five new tabs. Open a file A. Create five other tabs. Open a file B. Using CTRL-TAB, switch back to file A. You should be able to switch between A and B with only one CTRL-TAB.

Close and reopen Notepad++. It should be displaying the last file opened (A or B). If you press CTRL-TAB, you're not cycling between A and B anymore.

GiottoVerducci avatar Jun 04 '25 19:06 GiottoVerducci

I noticed something strange when I closed Notepad++: the "Document list" content was getting reordered just before the program closed.

GiottoVerducci avatar Jun 11 '25 14:06 GiottoVerducci

I looked into this and rom what I explored, the functionality seems to rely heavily on Windows-level handling (like accelerator tables and focus events), and I couldn't find a specific area in the Notepad++ codebase where the tab-switching history (MRU order) is stored or managed manually.

As a newbie to the codebase, I tried my best but couldn’t identify a way to hook into the exact logic controlling the Ctrl+Tab order ,it seems like it's tightly coupled with Windows message handling. Please feel free to correct me if I missed something ,I'm still learning!

Niranjen99 avatar Jun 19 '25 13:06 Niranjen99

I couldn't find a specific area in the Notepad++ codebase where the tab-switching history (MRU order) is stored or managed manually

Since the behavior is controlled by this option:

Image

did you try searching the codebase for what that does? And then proceed from there?

alankilborn avatar Jun 19 '25 13:06 alankilborn

I actually overlooked that MRU option , thanks for pointing it out. But from what I understand, that checkbox affects which tab gets activated when the current one is closed, based on most recently used order. But issue here is slightly different i think, the behavior on startup after restarting Notepad++. Even if we explicitly call the function to activate (activateAt) a different tab or hardcode (something other than index 0), it still ends up defaulting back to the first tab when the program relaunches. It seems like it's being overridden somewhere during initialization. Still investigating where that reset is happening, but appreciate the insight tho.

Niranjen99 avatar Jun 21 '25 03:06 Niranjen99

from what I understand, that checkbox affects which tab gets activated when the current one is closed, based on most recently used order.

That's true as well (in addition to affecting the order shown in the Ctrl+Tab popup).


But issue here is slightly different i think, the behavior on startup after restarting Notepad++.

Well...sure. This is because there is no memory of the previous run's tab order visiting.


it still ends up defaulting back to the first tab when the program relaunches

I can't reproduce this with a quick trial (via starting notepad++.exe via the command line, with no arguments). For me it starts up with the active tab being the tab that was active when I last shut N++ down.

alankilborn avatar Jun 21 '25 10:06 alankilborn

Correct, N++ reopens the last opened/active tab when launched. The idea would be to store the MRU order of the tabs, and restore it when starting N++. It’s likely that the MRU order is handled natively by the OS, so capturing it and restoring it may require some shenanigans.

Le sam. 21 juin 2025, 12:50, alankilborn @.***> a écrit :

alankilborn left a comment (notepad-plus-plus/notepad-plus-plus#16620) https://github.com/notepad-plus-plus/notepad-plus-plus/issues/16620#issuecomment-2993517053

from what I understand, that checkbox affects which tab gets activated when the current one is closed, based on most recently used order.

That's true as well (in addition to affecting the order shown in the Ctrl+Tab popup).

But issue here is slightly different i think, the behavior on startup after restarting Notepad++.

Well...sure. This is because there is no memory of the previous run's tab order visiting.

it still ends up defaulting back to the first tab when the program relaunches

I can't reproduce this with a quick trial (via starting notepad++.exe via the command line, with no arguments). For me it starts up with the active tab being the tab that was active when I last shut N++ down.

— Reply to this email directly, view it on GitHub https://github.com/notepad-plus-plus/notepad-plus-plus/issues/16620#issuecomment-2993517053, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBWJOFLCNQL7UDCE44USOT3EU2FRAVCNFSM6AAAAAB6MB7JL2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSOJTGUYTOMBVGM . You are receiving this because you authored the thread.Message ID: @.***>

GiottoVerducci avatar Jun 21 '25 13:06 GiottoVerducci

The idea would be to store the MRU order of the tabs, and restore it when starting N++.

Isn't that just a restatement of this entire issue?


It’s likely that the MRU order is handled natively by the OS

100% no.


so capturing it and restoring it may require some shenanigans

No "shenanigans", just some code.

alankilborn avatar Jun 21 '25 18:06 alankilborn

As an additional note, the Document list order is also lost when Notepad++ is closed.

GiottoVerducci avatar Jul 20 '25 11:07 GiottoVerducci