Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    one corner case where npp doesn't warn about "{file} doesn't exist anymore"

    Help wanted · · · – – – · · ·
    4
    11
    315
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MM-John
      MM-John last edited by

      In the normal case:

      If you edit a file in npp.
      Then go to another window and delete it (or rename it).
      Then come back to npp.
      It warns you:

      {file} doesnt exist any more. Keep file in editor?
      

      If you say ‘yes’, then the file is marked as modified.

      If you then close, you get a prompt to save the file.

      These are nice, helpful warnings that have saved me lots of time and re-work (thanks!).

      However there’s one particular sequence which avoids these warnings. Admittedly, it’s a corner case:

      Edit a file in npp.
      In npp do: file -> open
      It will default to the current file’s directory (folder) (or navigate there).
      rename the npp current file on disk from within in the file-open dialog box (I tested on windows only).
      ESC out of file-open.
      You are now back to npp with the current file in focus.
      However, now there is no file on written to disk corresponding to this buffer.
      You do not get a warning that the file doesn’t exist.
      (If you go to a different window and come back, you do.)
      And so the file is not marked as modified.
      Now if you close the file (without leaving npp), you get no prompt to save file.

      I think the issue is that it’s npp coming back in focus that triggers the check for “are all buffers still written to disk files.” And this particular sequence avoids npp changing out and back into focus.

      Another scenario might be a 2nd party (human remotely logged in, automated process) deleting a file while you’re working on it in npp.

      So, as I said, this is a corner case. I don’t expect anyone to fix it, I just thought it ought to be documented.

      Couple side notes:

      I have a process where I do this sequence because I sometimes like to save a file as a backup file, and rename is a good way of doing that preserving create/modify date-times, and doing it in the npp file-open dialog is convenient.

      Secondly, I noticed this because (for which I plan to create another post) I have started to hit Alt+X by accident. Alt+X appears to be an undocumented/unreported keyboard shortcut for file -> close (also ctrl+w). I hit Alt+X by accident these days because I installed the ‘XML Tools’ plugin which can be accessed via Alt+P, X and I’ve been hiting Alt+X as a typo lately.

      MM-John Neil Schipper 2 Replies Last reply Reply Quote 0
      • MM-John
        MM-John @MM-John last edited by

        FYI that was npp v8.3.3 64bit portable.

        1 Reply Last reply Reply Quote 0
        • Neil Schipper
          Neil Schipper @MM-John last edited by

          @mm-john said in one corner case where npp doesn't warn about "{file} doesn't exist anymore":

          and doing it in the npp file-open dialog is convenient

          I used to do that, but at some point I started to make use of File commands “Save a Copy As…” and Rename (latter also in tab right-click) which feel a bit safer because they’re not “sneaky”, ie, outside NPP’s awareness.

          MM-John 2 Replies Last reply Reply Quote 2
          • MM-John
            MM-John @Neil Schipper last edited by

            @neil-schipper Absolutely that’s an option. But that file has today’s date, not the original date of the file. For me that’s an important distinction.

            1 Reply Last reply Reply Quote 0
            • MM-John
              MM-John @Neil Schipper last edited by

              @neil-schipper Also, another alternative is File - Rename to backup file name. Then File -> save_as to original file name. That’s equivalent to what I’m doing. I find the file - open easier, but they’re close.

              Alan Kilborn 1 Reply Last reply Reply Quote 0
              • Alan Kilborn
                Alan Kilborn @MM-John last edited by Alan Kilborn

                @mm-john

                I understand the complaint. You should make a real issue out of it; see instructions HERE.

                As to your workflow, if your intent is to make a backup, why wouldn’t you copy the file to a new name rather than renaming it? You could even do this right in the File > Open dialog, as an alternative to the renaming operation you are doing now. This would seem to solve your problems (in the context of your workflow – it doesn’t solve anything about the issue with N++).

                Alan Kilborn 1 Reply Last reply Reply Quote 1
                • Alan Kilborn
                  Alan Kilborn @Alan Kilborn last edited by Alan Kilborn

                  @alan-kilborn said :

                  why wouldn’t you copy the file to a new name

                  Maybe I should be explicit in this procedure since it is arguably a little less obvious than renaming in the Open dialog:

                  • Do File > Open
                  • Locate and click on file to backup (example test.txt)
                  • Press Ctrl+c
                  • Press Ctrl+v

                  Windows will create a new file (example: test.txt - Copy) – with the same timestamp as the original – and show it to you in the directory listing.
                  Rename THAT file as you like.

                  MM-John 1 Reply Last reply Reply Quote 2
                  • mpheath
                    mpheath last edited by

                    @mm-john said in one corner case where npp doesn't warn about "{file} doesn't exist anymore":

                    …
                    So, as I said, this is a corner case. I don’t expect anyone to fix it, I just thought it ought to be documented.
                    …

                    The Open and Save Dialogs are blocking functions. All programs that call these functions will wait for the result to be returned. This is why you cannot interact with Notepad++ while the dialog is open, else you may get the not responding message if it were not disabled as Notepad++ is in a blocked state. This blocked state is probably causing the detection of the file state not to be done as Notepad++ is doing no processing at that time.

                    Modifying files while in these dialogs is what I would not recommend, as you have discovered with doing something unexpected during the task. This applies to any program that calls these dialog functions.

                    Alan Kilborn 1 Reply Last reply Reply Quote 1
                    • Alan Kilborn
                      Alan Kilborn @mpheath last edited by

                      @mpheath said in one corner case where npp doesn't warn about "{file} doesn't exist anymore":

                      Modifying files while in these dialogs is what I would not recommend, as you have discovered with doing something unexpected during the task.

                      This is a good recommendation, although, in the end, Notepad++ really bears the responsibility to have a “smart” reaction when users do “dumb” things.

                      1 Reply Last reply Reply Quote 0
                      • MM-John
                        MM-John @Alan Kilborn last edited by

                        @alan-kilborn Copying a file (in windows) preserves its Date modified (LastWriteTime) but it changes its Date created (CreationTime).

                        Rename does not change the Date created (CreationTime).

                        Both operations, however, change the Date accessed (LastAccessTime)

                        This gif illustrates in windows explorer: https://postimg.cc/N54cMZSh

                        Alan Kilborn 1 Reply Last reply Reply Quote 0
                        • Alan Kilborn
                          Alan Kilborn @MM-John last edited by Alan Kilborn

                          @mm-john

                          OK, not sure why you’re so particular about the timestamps (but you keep being you :-) ). I don’t really care to pursue further about that, as we’re moving into “off topic” land…

                          My diversion with the Ctrl+c/Ctrl+v thing was to point out how to create a copy of a file without changing its “modified” timestamp (the timestamp that means the most to ME). As noted, Save As and Save a Copy As both change this timestamp.

                          The relevant point was your main point in the first posting in this thread. I’ve recommended that you create an issue about that, so that’s all I’ve got.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Copyright © 2014 NodeBB Forums | Contributors