You are here

[Bug] Notepad++ loses session when opened with multiple files passed from Explorer

10 posts / 0 new
Last post
OsakaWebbie
Offline
Last seen: 2 months 1 week ago
Joined: 2012-02-16 02:11
[Bug] Notepad++ loses session when opened with multiple files passed from Explorer

I assumed this was a bug in Notepad++ itself, but when I reported it on the Github repo, others helped me realize that it only fails in the PA version. See that discussion for details: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14161

Summary: If NPP is closed but it had previously preserved content (files or unsaved content in tabs), and you open multiple files from File Explorer, your previous content is discarded. This does not happen with the NPP app downloaded from https://notepad-plus-plus.org/downloads/ but only the version installed by PortableApps.

How to replicate:

  1. With one or more non-empty files still in tabs, close NPP. (It doesn't matter if the files are saved or unsaved.)
  2. In File Explorer (or your favorite substitute like Directory Opus - it doesn't matter), select at least two files whose type is associated with NPP.
  3. Right-click and select Open.

The app will open with the new files, but the previous tabs of files/content will be gone. There is no warning and no apparent way to recover them.

Environment:
Windows 11 Home, 64-bit, OS build 22621.2283
Install path: C:\PortableStuff\PortableApps\Notepad++Portable (fails with either new or upgrade)
App version: 8.5.7 (also fails in 8.5.6)

Perhaps some might consider this an un-important edge case, but I often keep notes, in-process forum posts, etc. in NPP, and I expect such content to stay there no matter what. I have done this for years with no trouble. I have no idea whether this is the first time I've tried to open multiple files from File Explorer with NPP closed, but it doesn't matter - it should work. This is clearly a bug in the PA version, as you can see by the combination of tests I did and reported in the Github thread. I currently have the notepad-plus-plus.org in my PA folder structure, so I can start it from the PA launcher, but I know that PA will not keep it updated, so that's not a good long-term solution.

John T. Haller
John T. Haller's picture
Offline
Last seen: 3 hours 49 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
How Launching?

How do you have Notepad++ Portable associated with files? If you associated it within Notepad++ itself, then it's running in local mode, so it is bypassing our launcher. For comparison, do the same test by dragging the files you want to open onto NotepadPlusPlusPortable.exe.

Sometimes, the impossible can become possible, if you're awesome!

OsakaWebbie
Offline
Last seen: 2 months 1 week ago
Joined: 2012-02-16 02:11
Launch using "Open With"

I associated it in File Explorer (well, technically Directory Opus, but that uses the underlying File Explorer functions). The app name is worded as "Notepad++ Portable (PortableApps.com Launcher)".

When I drag multiple files onto the .exe file, it seems to work okay. It only fails when I use "Open" (or "Open With").

It never even occurred to me to associate files from within NPP itself; I didn't even know it was possible. So I tried it - I had to run the .exe directly (rather than through the Launcher) in order to open it in Administrator mode, but I did that and put .php in the associated list. That changed the associated app name as seen in File Explorer to simply "Notepad++". However, the behavior did not change - if I drag files to the .exe, it preserves previous tabs, but if I right-click and select "Open", previous tabs are discarded.

Are you able to replicate this bug yourself?

John T. Haller
John T. Haller's picture
Offline
Last seen: 3 hours 49 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
How Defined in Directory Opus?

Dragging multiple files onto Notepad++Portable.exe in Explorer shows that when called correctly, the existing settings and everything are preserved and your tabs are visible. So, how is Directory Opus passing the files to Notepad++Portable.exe?

Sometimes, the impossible can become possible, if you're awesome!

OsakaWebbie
Offline
Last seen: 2 months 1 week ago
Joined: 2012-02-16 02:11
How? Same as File Explorer

I have no idea what is going on under the hood, but this isn't just a Directory Opus thing - it fails exactly the same way in File Explorer. (The only difference is that File Explorer doesn't offer "Open With" if multiple files are selected, so you have to first associate the file type so you can use "Open".) Assuming you have a file type that is associated with NPP (whether that association was made in the app or via File Explorer doesn't matter), make sure there is at least one non-empty tab in the app, and then close the app. Then in File Explorer, select multiple files, right-click, and choose "Open". NPP will open with only the new files - the previous tab(s) will be gone.

John T. Haller
John T. Haller's picture
Offline
Last seen: 3 hours 49 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Associated With?

Are you associating it with Notepad++Portable.exe or with notepad++.exe? If the former, which you must do manually, it's just like dragging files onto Notepad++Portable.exe. If the latter, which is what happens when you associate it via the app, it will run in local mode and it won't show any of your existing tabs since it will be using a separate set of settings.

Sometimes, the impossible can become possible, if you're awesome!

OsakaWebbie
Offline
Last seen: 2 months 1 week ago
Joined: 2012-02-16 02:11
Notepad++Portable.exe

I'm associating with: C:\\PortableStuff\PortableApps\Notepad++Portable\Notepad++Portable.exe But it is NOT acting the same as dragging files onto Notepad++Portable.exe.

You keep asking me questions about my setup - does that mean you are unable to replicate the behavior I'm seeing? I assumed it would happen to anyone who did the steps I did, but maybe not.

John T. Haller
John T. Haller's picture
Offline
Last seen: 3 hours 49 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Working Here

I associated it in Q-Dir to open *.txt with P:\PortableApps\Notepad++Portable\Notepad++Portable.exe and it opens just fine. Opens the saved tabs alongside anything I double click to open. A proper association and dragging and dropping a file onto Notepad++Portable.exe should result in the exact same thing. If they don't, there's something up with the association. Did you typo the extra backslash in there?

Sometimes, the impossible can become possible, if you're awesome!

OsakaWebbie
Offline
Last seen: 2 months 1 week ago
Joined: 2012-02-16 02:11
Double-clicking only opens ONE file

Double-clicking a single file works fine for me, too. The problem only happens when opening more than one file. To do that, you can't double-click - you have to first select multiple files (holding Ctrl or Shift while clicking subsequent files), then right-click and choose "Open".

John T. Haller
John T. Haller's picture
Offline
Last seen: 3 hours 49 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Confirmed

Ah ok, I was able to reproduce it now. Sorry, it seems the file managers I was trying to reproduce the issue only support opening a single file at a time with an internal association, not two, which is why I was having an issue replicating it. I associated it in Windows and reproduced your issue. I think I have an idea what may be causing it... I'm going to look further.

UPDATE: It's what I thought. Windows Explorer is launching the app twice in rapid succession rather than passing the multiple files on a single command line. That's why it works when you drag the files (passed on one command line) but not when you open a couple in Windows Explorer (launching twice really quickly). As the launcher is starting up, the second instance is started before the first instance has finished setting itself up, so the session file is getting overwritten by the second instance as the first is still loading. This is an issue with the PA.c Launcher itself in conjunction with how some apps load. It likely wasn't an issue when load times were a few milliseconds slower, but it is now.

To avoid triggering the bug for right now, make sure Notepad++ Portable is already open before opening multiple files at the same time.

Sometimes, the impossible can become possible, if you're awesome!

Log in or register to post comments