Community
    • 登入

    Enable Session Snapshot and Periodic Backup Box Unchecked

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    19 貼文 8 Posters 5.4k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Scott SumnerS
      Scott Sumner
      最後由 編輯

      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.

      Steve HoyerS 1 條回覆 最後回覆 回覆 引用 2
      • PeterJonesP
        PeterJones
        最後由 編輯

        @Steve-Hoyer ,

        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 -nosession settings. 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.xml with 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.xml claims 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.

        Steve HoyerS 1 條回覆 最後回覆 回覆 引用 2
        • Steve HoyerS
          Steve Hoyer @Scott Sumner
          最後由 編輯

          @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.

          Scott SumnerS 1 條回覆 最後回覆 回覆 引用 1
          • Steve HoyerS
            Steve Hoyer @PeterJones
            最後由 編輯

            @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.

            :)

            1 條回覆 最後回覆 回覆 引用 1
            • Scott SumnerS
              Scott Sumner @Steve Hoyer
              最後由 編輯

              @Steve-Hoyer

              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).

              1 條回覆 最後回覆 回覆 引用 2
              • mjsloweM
                mjslowe
                最後由 mjslowe 編輯

                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 diff from 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 diff to 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 diff command which is causing the option to un-tick.

                The following use case is causing it to happen:

                1. Close notepad++ with multiple unsaved documents and the backup option ticked
                2. run arc diff command from gitbash (which will implicitly run "C:\Program Files (x86)\Notepad++\notepad++.exe\" -multiInst -nosession)
                3. Save and close the opened notepad++ window
                4. 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:

                1. Find a way to modify the notepad++ command so that it doesn’t break my normal notepad++ setup
                2. 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?

                1 條回覆 最後回覆 回覆 引用 1
                • PeterJonesP
                  PeterJones
                  最後由 編輯

                  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:

                  1. Does the arc diff work if you just set it to a normal "C:\Program Files (x86)\Notepad++\notepad++.exe\" without the -multiInst -nosession options? Because that way, Notepad++ wouldn’t be changing between the two modes and getting confused.

                  2. 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 diff to 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.

                  1 條回覆 最後回覆 回覆 引用 3
                  • mjsloweM
                    mjslowe
                    最後由 編輯

                    Thanks for the response @Peter-Jones

                    I had a go at changing the arc diff command 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 -nosession in the first place.

                    With that ruled out, I will take a look at using portable notepad++

                    1 條回覆 最後回覆 回覆 引用 1
                    • mjsloweM
                      mjslowe
                      最後由 編輯

                      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 diff command doesn’t disable backups makes me think I would be better specifically setting arc diff to use an editor other than notepad++ (eg vim which is pre-installed with gitbash)

                      1 條回覆 最後回覆 回覆 引用 1
                      • PeterJonesP
                        PeterJones
                        最後由 編輯

                        @mjslowe said:

                        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 .bat file:

                        @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.

                        Good luck.

                        1 條回覆 最後回覆 回覆 引用 1
                        • PeterJonesP
                          PeterJones
                          最後由 編輯

                          PS: and thanks for prompting me to create that batch file… I’d not known (or forgotten) that the -multiInst -nosession put Notepad++ into blocking mode, so I hadn’t set Notepad++ as the editor for SVN; because of this, I am now able to. :-)

                          1 條回覆 最後回覆 回覆 引用 1
                          • mjsloweM
                            mjslowe
                            最後由 編輯

                            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.

                            1 條回覆 最後回覆 回覆 引用 1
                            • Ron LittleR
                              Ron Little
                              最後由 編輯

                              I got caught up in this unexpected behavior, too.

                              For me, the steps were:

                              1. 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

                              2. 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.

                              3. Something would cause me to close Notepad++, like restarting Windows or having a mandatory Windows update that forcibly closed all apps.

                              4. 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.

                              Suggested solutions:

                              1. 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
                              2. What if the -nosession flag did not save user settings at all and the user preferences dialog was disabled? OR
                              3. 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.

                              Meta ChuhM 1 條回覆 最後回覆 回覆 引用 1
                              • Meta ChuhM
                                Meta Chuh moderator @Ron Little
                                最後由 Meta Chuh 編輯

                                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)

                                • extract npp.7.6.6.bin.zip to e.g. C:\PortableApps\Notepad++.

                                • open the C:\PortableApps\Notepad++ folder and start this portable version by double-clicking on notepad++.exe inside this folder.

                                • make all settings you need at this portable version.

                                • use ‘C:\PortableApps\Notepad++\notepad++.exe’ -multiInst -notabbar -nosession -noPlugin as your command line.

                                this way your installed notepad++ never gets touched, as the additional portable version is completely self contained.

                                Ron LittleR 1 條回覆 最後回覆 回覆 引用 2
                                • Ron LittleR
                                  Ron Little @Meta Chuh
                                  最後由 編輯

                                  @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.

                                  1 條回覆 最後回覆 回覆 引用 3
                                  • AndreCunhaA
                                    AndreCunha
                                    最後由 編輯

                                    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.

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • 第一個貼文
                                      最後的貼文
                                    The Community of users of the Notepad++ text editor.
                                    Powered by NodeBB | Contributors