Notepad++ lost track of open files / why?
-
That is unfortunate.
If you haven’t done too much in Notepad++ since it lost track of those, you might be able to recover at least the list of unsaved tabs: @sfcfs shared a c# script a few days ago which claims to rebuild session.xml to point to any of the unsaved-backup files that it can find. (Of course, that requires that you know how to run a c# script… I have pinged @sfcfs in the other topic to add quick instructions for C# newbies so that the script can be useful to more people)
-
@PeterJones said in Notepad++ lost track of open files / why?:
quick instructions for C# newbies
I would think that C# requires Visual Studio, which is fine for those that already have it, but I’d go out on a limb and say the typical Notepad++ user wouldn’t. Getting VS just for this is rather a big ask of someone.
Of course, if the author of that C# were to build the .exe from it, and post that somewhere, and people trusted that the .exe was not evil, it is perhaps reasonable that people could run it (only requiring perhaps a .NET framework install – maybe that is too big of an ask as well).
-
A few years ago, before I had visual studio, I had thought I had compiled some C# using just the csc.exe that came with the .NET framework (
c:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
or similar)… but I haven’t found my notes yet, and when I tried that with @sfcfs script, which I saved asrecover-lost-session.cs
, I got:recover-lost-session.cs(6,1): error CS0116: A namespace cannot directly contain members such as fields or methods recover-lost-session.cs(13,8): error CS1001: Identifier expected recover-lost-session.cs(13,10): error CS1518: Expected class, delegate, enum, interface, or struct
But this isn’t a C# help forum, so I think I’ll stop trying.
-
Maybe a PythonScript port of the C# code, so the “ask” only becomes obtaining a Notepad++ plugin?
But I’m not going to do that, as my interest level is LOW for it. :-)
-
thanks gentlemen. lesson learned. fortunately, most of my tabs were in fact saved in named files so i didn’t lose much. i just have to re-open what i prefer to leave open for my purposes.
i read thru the c# script and notes; my appdata backup folder is actually empty, so it won’t help me.
thanks again.
-
@Fabian-Santiago said in Notepad++ lost track of open files / why?:
most of my tabs were in fact saved in named files
This is good.
so i didn’t lose much.
Thankfully…
all tabs were closed, unexpectedly
We realize that loss of current session info – which sounds like the largest component of YOUR loss – is a tangible loss, as it takes effort to recreate it. :-(
-
Hello @Fabian-Santiago ,
I’m sorry for your problem loosing the session file.
If you are willing to help diagnose the problem you could look for an xml file named nppSession… something (you will recognize it when you see it :) ) in your user config folder (C:\Users\your_user_name\Application Data\Notepad++) and if you find it upload it here (or its contents).
It shouldn’t reveal any personal data only the process of closing Notepad++ before the reboot for updates but you better inspect its contents before sharing it here.That will probably be useful and surely appreciated, thanks.
-
@pnedev i don’t see a folder as you described. i assume you mean this folder: “C:\Users\fabian\AppData\Roaming\Notepad++”
i don’t see any such file. its contents are:
and my current session.xml is pretty bland:
<?xml version=“1.0” encoding=“UTF-8” ?>
<NotepadPlus>
<Session activeView=“0”>
<mainView activeIndex=“0” />
<subView activeIndex=“0” />
</Session>
</NotepadPlus>anything else i can help provide? thanks for your help.
-
@Fabian-Santiago said in Notepad++ lost track of open files / why?:
anything else i can help provide? thanks for your help.
@pnedev was asking for the contents of the
nppLogNulContentCorruptionIssue.log
file, which was in your directory listing screenshot. That file contains the debug information necessary for the developers to fix the problem. -
@Alan-Kilborn said in Notepad++ lost track of open files / why?:
Maybe a PythonScript port of the C# code, …
But I’m not going to do thatOkay, if you won’t, I will: posted in the other thread.
-
That is exactly the folder I meant and the file we are looking for is
nppLogNulContentCorruptionIssue.log
as @PeterJones pointed out. I’m sorry for my very inaccurate description before, I really forgot the exact folder on Windows OS and the name of the log file (it appears on very rare and obviously unfortunate occasions).
So it will be helpful if you could upload that file (or its contents) here but please check to be sure it is not revealing any sensitive data.
Thanks. -
-
@pnedev sorry my reply took so long. here you are. it won’t let me upload / attach the log file here so this is the content (there was nothing sensitive in it so this is fully intact):
2022-07-25 11:08:22 WM_QUERYENDSESSION =====================================
2022-07-25 11:08:24 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is opened.
2022-07-25 11:08:24 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml 8015/8015 bytes are written.
2022-07-25 11:08:24 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is closed.
2022-07-25 11:08:24 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is opened.
2022-07-25 11:08:24 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml 3683/3683 bytes are written.
2022-07-25 11:08:24 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is closed.
2022-07-25 11:08:24 WM_ENDSESSION
2022-07-25 11:08:24 WM_DESTROY
2022-08-19 10:43:58 WM_QUERYENDSESSION =====================================
2022-08-19 10:43:58 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is opened.
2022-08-19 10:43:58 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml 8256/8256 bytes are written.
2022-08-19 10:43:58 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is closed.
2022-08-19 10:43:58 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is opened.
2022-08-19 10:43:58 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml 6047/6047 bytes are written.
2022-08-19 10:43:58 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is closed.
2022-08-19 10:43:58 WM_ENDSESSION
2022-08-19 10:43:58 WM_DESTROY
2022-08-23 12:10:06 WM_QUERYENDSESSION =====================================
2022-08-23 12:10:07 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is opened.
2022-08-23 12:10:07 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml 8256/8256 bytes are written.
2022-08-23 12:10:07 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is closed.
2022-08-23 12:10:07 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is opened.
2022-08-23 12:10:07 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml 5434/5434 bytes are written.
2022-08-23 12:10:07 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is closed.
2022-08-23 12:10:07 WM_ENDSESSION
2022-08-23 12:10:07 WM_DESTROY
2022-08-23 23:44:57 WM_QUERYENDSESSION =====================================
2022-08-23 23:44:58 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is opened.
2022-08-23 23:44:58 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml 8256/8256 bytes are written.
2022-08-23 23:44:58 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is closed.
2022-08-23 23:44:58 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is opened.
2022-08-23 23:44:58 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml 5430/5430 bytes are written.
2022-08-23 23:44:58 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is closed.
2022-08-23 23:44:58 WM_ENDSESSION
2022-08-23 23:44:58 WM_DESTROY
2022-09-12 14:54:17 WM_QUERYENDSESSION =====================================
2022-09-12 14:54:17 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is opened.
2022-09-12 14:54:17 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml 8352/8352 bytes are written.
2022-09-12 14:54:17 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is closed.
2022-09-12 14:54:17 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is opened.
2022-09-12 14:54:17 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml 3707/3707 bytes are written.
2022-09-12 14:54:17 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is closed.
2022-09-12 14:54:17 WM_ENDSESSION
2022-09-12 14:54:17 WM_DESTROY
2022-09-14 01:23:48 WM_QUERYENDSESSION =====================================
2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is opened.
2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml 8366/8366 bytes are written.
2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is closed.
2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is opened.
2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml 3709/3709 bytes are written.
2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is closed.
2022-09-14 01:23:48 WM_QUERYENDSESSION =====================================
2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is opened.
2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml 9398/9398 bytes are written.
2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\config.xml is closed.
2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is opened.
2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml 193/193 bytes are written.
2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml is closed.
2022-09-14 01:23:48 WM_ENDSESSION
2022-09-14 01:23:48 WM_DESTROY -
@Fabian-Santiago ,
Thank you. I hope it will be useful and give some insight on the cause of the problem.BR
-
Thanks for the log!
Do you have your N++ autoupdate set ON? (Preferences -> MISC. -> Enable Notepad++ auto-updater checked)
This is the same pattern as in here.
The relevant thing is the last surprising duplicate of the WM_QUERYENDSESSION log, where the session.xml file evidently gets emptied (“2022-09-14 01:23:48 C:\Users\fabian\AppData\Roaming\Notepad++\session.xml 193/193 bytes are written.”)
So we are getting a little bit closer - now let’s discuss how this could happen.
If there were slightly different times in the duplicate log items at the end, I could suspect some N++ multi-instancing problem or N++ zombie/crashed process behind, but we have the same log-time everywhere. So I do not think so.
If it was a racing condition, the last two WM_QUERYENDSESSION items would probably be mixed together. So I do not think so.
I’m wondering if it cannot be a coincidence with the N++ autoupdating.
Any other thoughts?
-
@xomx
At the same time config.xml gets 1032 bytes bigger. Quite a big difference. -
@xomx yes i do:
-
Maybe it could be interesting to see the content of such config.xml too.
Now about something else - I have just checked the relevant N++ shutdown source code and I have the following crazy idea (I have not tested/debugged that yet):
- the WM_QUERYENDSESSION and WM_CLOSE messages share the same code part
- at the standard (user initiated closing of the N++ app) N++ shutdown, the N++ receives only the WM_CLOSE one from these two
- when a Windows restart occurs, while the N++ is still opened, the N++ receives both of them, WM_QUERYENDSESSION 1st and the N++ executes the same code part as the WM_CLOSE, then returns TRUE (when an user did not cancelled the Windows restart/shutdown)
- when an app sent TRUE to the Windows OS as a response to the WM_QUERYENDSESSION, that app shutdown continues, so the app should obtain the WM_CLOSE sometime later!
- and I think that this “double-execution” of the same code part can be the culprit
Look at this part - I think that during the 1st execution all the opened files are closed, so at the 2nd execution the session has not any opened files to store!
If I am right, the solution is to handle the WM_QUERYENDSESSION and WM_CLOSE separately.
-
@xomx said in Notepad++ lost track of open files / why?:
If I am right, the solution is to handle the WM_QUERYENDSESSION and WM_CLOSE separately.
I haven’t looked at the code myself yet but that is a very good assumption @xomx .
Could you also share your
Backup
settings tab?
Thank you once again for the debug input. -
@pnedev yes:
-
@xomx , All,
I suspect that on occasions the periodic session backup might be triggered while in the process of WM_QUERYENDSESSION but that needs further investigation.
BR