Enable Session Snapshot and Periodic Backup Box Unchecked
Hi, the thread at Running multiple instances of Notepad++ with regular autosave kind of turned into an editorial on unsaved “new 1” tabs before the issue at hand was addressed.
I’d like to revive the discussion about the “Enable session snapshot and periodic backup” checkbox becoming unchecked. It doesn’t seem like a desirable behavior, regardless of how the feature is meant to be used.
I rarely use multiple instances of NPP. Every time I do, the session snapshot and periodic backup box becomes unchecked. Re-checking the box restarts backups immediately, and in the specified directory, but the box comes unticked after an indeterminate amount of time regardless of whether I’ve opened a second instance of NPP since the last occurrence.
I’m glad to provide more information.
So I’ll ignore the real topic of this thread, but maybe I won’t go totally off-topic…
I’d like to ask what people find so useful about being able to run multiple instances of Notepad++. Okay, so there might be some obvious things about this (that I should know and in reality likely do), but I’m gonna “play dumb” and see what people respond with, if anyone cares to.
Thank you for the clear sequence: I was able to reproduce your issue with 7.5.8 32bit. You are right, that does seem strange behavior.
I believe I can interpret it: the original was opened with session-snapshot enabled (obviously). When you split out a tab to a new instance, NPP probably internally used the
-multiInst -nosessionsettings. So now you’ve got two instances of NPP – the original with session, and the new without session. When you close the original, it compares its settings with the
config.xml, doesn’t see a difference, so just exits. When you close the new, it compares its settings with the
config.xml, sees a difference, saves a new
config.xmlwith session-snapshot disabled, and exits. Thus, when you reload, it now has session-snapshot disabled.
I am not sure there would be a way to fix this, because I am not sure how NPP could tell the difference between “I was intentionally opened with -nosession, and my user wants me to save that setting for the future” (which is the current behavior), and “I was unknowingly opened with -nosession, and my user will be very confused if I save that setting for the future”… because really, all NPP knows is “I have sessions disabled, the
config.xmlclaims sessions are enabled, so I need to overwrite that setting to match my current state.”
If you want the developer to have a better chance of finding out about this , I would suggest following the instructions in this FAQ to make an official bug report. Feel free to link to this topic, and/or quote my interpretation paragraphs. I’m not sure how a compromise could be made between the two reasons for the internal state, but the developers, knowing the guts of the program much better than I, might be able to come up with something.
@Scott-Sumner I use it this way periodically to compare to files visually on screens, side by side. I often use the compare plug-in too, but sometimes I need to have two separate windows.
@PeterJones Now that I’ve nailed down the ‘why’ and the ‘how to avoid’ and the ‘how to fix when I forget to avoid’, I understand the why and feel content.
I use it this way periodically to compare to files visually on screens, side by side
Have you tried the secondary view feature to keep things within a single instance? (Right-click a tab and choose Move to Other View).
Apologies for commenting on a 6 months old thread but after trying to figure out what was going wrong with my notepad++, I came across this thread which finally made me figure out the issue and made me realise I have an alternate use case that is probably worth highlighting.
I make heavy use of Phabricator coupled with git for version control. As part of this, whenever I create a new change request for a repository, I have to run the command
arc difffrom gitbash on my Windows computer. This will open a text editor of my choice where I: fill in details of the commit, save and then close the text editor.
Per https://secure.phabricator.com/book/phabricator/article/arcanist_windows/ to configure notepad++ to be used as my preferred editor I have to setup
arc diffto run the following command:
"C:\Program Files (x86)\Notepad++\notepad++.exe\" -multiInst -nosession
For a while now I have noticed the “Enable session snapshot and periodic backup” option will randomly un-tick itself wiping out my unsaved files. I have been unable to determine why this is happening for ages however this thread had made me realise that it is my frequent running of the
arc diffcommand which is causing the option to un-tick.
The following use case is causing it to happen:
- Close notepad++ with multiple unsaved documents and the backup option ticked
arc diffcommand from gitbash (which will implicitly run
"C:\Program Files (x86)\Notepad++\notepad++.exe\" -multiInst -nosession)
- Save and close the opened notepad++ window
- Reopen notepad++. The unsaved documents will have disappeared and the backup option is now unticked
I therefore need some advice from this community as to how to resolve this. The way I see it I have 2 options:
- Find a way to modify the notepad++ command so that it doesn’t break my normal notepad++ setup
- Submit a bug request to prevent the running of the above command from breaking my normal setup.
Is anybody able to advise what my best option here is?
Welcome to the Notepad++ Community, @mjslowe.
I think we’re more likely to
Find a way to modify the notepad++ command so that it doesn’t break my normal notepad++ setup
I say this because Notepad++ is really more designed to either always be used with sessions, or never be used with sessions. To try to mix the two behaviors is risky.
The two ideas I would try, if it were me having this problem:
arc diffwork if you just set it to a normal
"C:\Program Files (x86)\Notepad++\notepad++.exe\"without the
-multiInst -nosessionoptions? Because that way, Notepad++ wouldn’t be changing between the two modes and getting confused.
My second idea would be to grab a second copy of Notepad++ – this time, the “portable” (the zip or 7z file from the downloads page), and put it in a different location. You could then have your normal notepad++, with all the file associations, stay on the installed copy; you could then point
arc diffto the portable copy, which would always be opened in
-multiInst -nosession, so it wouldn’t have any change of state there, either.
Some unsolicited advice: You said,
Close notepad++ with multiple unsaved documents and the backup option ticked
My unsolicited advice to you would be to not rely on long-term “unnamed” file storage. Taking ownership and control of your own files, including backups and version control, is something very important; there are times when events outside of Notepad++ control will cause the Notepad++ “unsaved file” saved location to be corrupted, and you may lose data. My personal advice is save early, save often; commit early, commit often. This is not something that’s unique to Notepad++; I have had the auto-saves by MS Word get corrupted when something goes wrong with Windows. Basically, if you are not in full control of your saves and your backups/version control, there is always the chance that a random Windows issue will cause data loss, whatever application you are running to manipulate the data.
Thanks for the response @Peter-Jones
I had a go at changing the
arc diffcommand to only run
"C:\Program Files (x86)\Notepad++\notepad++.exe\"however Phabricator did not like this at all.
The file for the commit opened in my already open notepad++ window but when I tried to save, it complained I needed to reopen notepad++ so that it was running as Administrator. I reran the test with notepad++ opened as Administrator but when I tried to save, it simply stated “Save Failed: Please check if this file is opened in another program”
I then tried to modify my command to run as
"C:\Program Files (x86)\Notepad++\notepad++.exe\" -multiInst. This was technically better in that I was able to save my commit however, in this case it opened an additional copy of all the files I already had open in notepad++ (including both saved and unsaved documents). I then had to close not just the tab for the commit but the entire window containing the additionally opened copy of all my files. As such this doesn’t seem like the preferred option either.
The above 2 tests probably explain why the recommended command from Phabricator included
-multiInst -nosessionin the first place.
With that ruled out, I will take a look at using portable notepad++
To confirm, installing an additional copy of notepad++ seems to work though it very much feels like a workaround.
The point at which I need 2 installations of notepad++ on my computer to ensure running the
arc diffcommand doesn’t disable backups makes me think I would be better specifically setting
arc diffto use an editor other than notepad++ (eg vim which is pre-installed with gitbash)
though it very much feels like a workaround.
Yes, this is the Community forum – the community of Notepad++ users. This isn’t the feature-request/bug-report tracker (see the FAQ for that).
Your application didn’t work with Notepad++, so I provided some potential workarounds.
As another alternate workaround, instead of the portable Notepad++, create a shell script / batch file, and use that as the editor asscoiated with
arc diff. The script would need to look something like the following
@echo off rem backup the config files copy "%AppData%\Notepad++\config.xml" "%AppData%\Notepad++\config.xml.arcdiffbak" copy "%AppData%\Notepad++\session.xml" "%AppData%\Notepad++\session.xml.arcdiffbak" rem run notepad++ for the commit message rem this is a blocking-instance, so the commit will wait for this instance of notepad++ to be exited "c:\program files (x86)\notepad++\notepad++.exe" -multiInst -nosession %* rem restore the config files copy "%AppData%\Notepad++\config.xml.arcdiffbak" "%AppData%\Notepad++\config.xml" copy "%AppData%\Notepad++\session.xml.arcdiffbak" "%AppData%\Notepad++\session.xml"
This creates a backup of your current config, runs notepad++; then, when you close notepad++, it will copy the backup config back.
I just used my command-line version of TortoiseSVN (which, like your Arcanist User Guide, wants an editor in blocking mode), and verified that the script above will properly be in blocking mode, and will make sure that it restores config.xml and session.xml to the pre-existing version once the temporary instance of Notepad++ is done.
PS: and thanks for prompting me to create that batch file… I’d not known (or forgotten) that the
-multiInst -nosessionput Notepad++ into blocking mode, so I hadn’t set Notepad++ as the editor for SVN; because of this, I am now able to. :-)
Thanks for the bat script suggestion.
I will have a look at that as an alternative. If I can’t get that working I will probably stick with the 2 notepad++ installations
It looks like there are multiple issues raised in github for this by the way (https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4648) so we may get a permanent fix for it.
I got caught up in this unexpected behavior, too.
For me, the steps were:
I use git on Windows, and the recommended solution for making git work with Notepad++ is:
$ git config core.editor
‘C:\Program Files (x86)\Notepad++\notepad++.exe’ -multiInst -notabbar -nosession -noPlugin
I would keep Notepad++ open all the time with multiple unsaved .txt files. I love this feature, that I can use Notepad++ as a scratch workspace, and that my session and edited text files are always backed up and can be restored in case of some sudden Windows crash or restart. It’s the #1 feature of Notepad++ to me.
Something would cause me to close Notepad++, like restarting Windows or having a mandatory Windows update that forcibly closed all apps.
Upon restarting Notepad++, my session was gone and the “Enable session snapshot and periodic backup” setting was cleared. I would have to find where Notepad++ was keeping my backups and I would carefully restore my session by hand. This would make me want to give up on Notepad++ and stop recommending it to others.
So, before giving up for good, I’m glad I found this thread. Unknowingly to me, the “Enable session snapshot and periodic backup” setting was getting cleared by using git.
- What if the -nosession flag caused the “Enable session snapshot and periodic backup” user preference to be disabled in the Preferences dialog box, and that this preference would not be persisted by this instance of Notepad++ (thus preserving the original value in the persisted user settings file)? OR
- What if the -nosession flag did not save user settings at all and the user preferences dialog was disabled? OR
- What if the -nosession flag caused a special no-session set of settings to be saved/loaded to/from a special “no-settings” user settings file?
With the way things are now, as I see it, no one should use Notepad++ with git.
welcome to the notepad++ community, @Ron-Little
as -multiinst and -nosession is incompatible with session snapshots and periodic backups, the best practice is, to keep your installed notepad++ as it is, and to use a secondary portable notepad++ for git.
download the notepad++ 7.6.6. portable version from >>> here <<<.
(the portable version does not require any installation and runs completely independent and isolated from your installed version. all custom settings, as well as any stuff you might want to try at the portable version, will not modify your installed version)
C:\PortableApps\Notepad++folder and start this portable version by double-clicking on
notepad++.exeinside this folder.
make all settings you need at this portable version.
‘C:\PortableApps\Notepad++\notepad++.exe’ -multiInst -notabbar -nosession -noPluginas your command line.
this way your installed notepad++ never gets touched, as the additional portable version is completely self contained.
@Meta-Chuh Thank you for the work-around of using a portable notepad++ for git. I would expect that to work, but I haven’t tested that, as I had already switched to using Notepad.exe for git.
I have had this problem for quite some time but have never bothered to go after it.
Today, after once again losing a few scratch texts because of this ongoing issue, I have found this thread and also a few related open issues on Notepad++ Issues tracker:
- Issue: Default session’s unsaved files are lost (from session’s XML file) after closing Notepad++ in a different session
- ‘enable session snapshot’ gets disabled occasionally
- Saved Sessions lost
- Notepad++ resets my auto-backup setting after I perform a git commit with it.
- Backup is broken in several ways with multiple instances
This is particularly unfortunate because Git installer for Windows itself actually offers to set up Notepad++ as the default editor for commits.
Setting up a portable version just for this seems a bit too much, also it would then be annoying to manually keep both Notepad++ configurations in sync. It is sad, but I have decided to do the same as @Ron-Little and simply use Windows’ Notepad.exe for Git and avoid this problem altogether.