Community
    • Login

    Notepap++ asks if the file should be reloaded after manual reload

    Scheduled Pinned Locked Moved General Discussion
    9 Posts 3 Posters 1.3k Views
    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.
    • Michi KaaM
      Michi Kaa
      last edited by

      I have configured Ctrl+R for reloading the current file. In more recent versions I encountered the following behaviour:

      • I have a logfile open which a running process is logging into
      • I want to refresh the file (since “Monitorng tail -f” doesn’t work as I expect it) by pressing Ctrl+R

      what happens:

      • the file is being immediateley reloaded after Ctrl+R
      • every now and then Notepad++ asks me if it should reload the file for me, because it was modified externally, this only happens, if I’m right, when the process logger appended to the file since the last reload and there really is new content in the file. At the moment i press Ctrl+R I see new lines being displayed and then there is the dialog"[…] Do you want to reload it?"

      What I’d expect is, that this dialog doesn’t show up after a manually triggered reload.

      Or did I miss something?

      EkopalypseE Alan KilbornA 2 Replies Last reply Reply Quote 0
      • EkopalypseE
        Ekopalypse @Michi Kaa
        last edited by

        @Michi-Kaa

        I assume this is a coincident.
        If it was programmed that a manual reload triggers a file reload dialog,
        then it would happen always.
        As it only happens now an then I think that a real update to
        that file has happened as well.
        Afaik there are two ways to configure the file monitor in this regards.

        1. getting the dialog that there was an update (default) or
        2. enable silent updating, (no dialog)

        Config can be changed in settings->preferences->MISC.
        tick or untick Update silently in file status auto-detection

        1 Reply Last reply Reply Quote 2
        • Michi KaaM
          Michi Kaa
          last edited by

          Thank you for your suggestion. But for me, in other cases, I want to be informed, if another process manipulated an opened file. So enabling silent updating is no solution for me.
          I’d hope, that being asked, if the file should be reloaded after a manual reload has been triggered, is considered a bug, and will be fixed in a future version.

          EkopalypseE 1 Reply Last reply Reply Quote 0
          • EkopalypseE
            Ekopalypse @Michi Kaa
            last edited by

            @Michi-Kaa

            I’d hope, that being asked, if the file should be reloaded after a manual reload has been triggered, is considered a bug, and will be fixed in a future version.

            if you find a reliable way how to get this happen, then one might be able to see if this
            can be changed in source code but currently I think it was just a coincident that a
            manual reload and an update notification occurred at the same time.

            1 Reply Last reply Reply Quote 1
            • Michi KaaM
              Michi Kaa
              last edited by Michi Kaa

              It is perfectly reproducible:

              C:\Users\me>ping -n 1000 localhost > ping.txt
              

              And now open ping.txt and press Ctrl+R every two seconds, make sure not to wait longer than it will take to ping 1000 times.

              Notepad++ v7.7.1 (32-bit)

              1 Reply Last reply Reply Quote 1
              • Michi KaaM
                Michi Kaa
                last edited by

                @Ekopalypse could you reproce the behaviour? If yes, what do you think? Desired or undesired behaviour? Also happens in v7.8.1 (64-bit)

                EkopalypseE 1 Reply Last reply Reply Quote 0
                • Alan KilbornA
                  Alan Kilborn @Michi Kaa
                  last edited by

                  @Michi-Kaa said in Notepap++ asks if the file should be reloaded after manual reload:

                  At the moment i press Ctrl+R I see new lines being displayed and then there is the dialog"[…] Do you want to reload it?"

                  I would say that this is a bug only if we know for sure that after the manual reload that there have been no further external changes to the file…and then the prompt appears.

                  1 Reply Last reply Reply Quote 1
                  • EkopalypseE
                    Ekopalypse @Michi Kaa
                    last edited by Ekopalypse

                    @Michi-Kaa

                    could you reproce the behaviour?

                    Yes and no - it happens sometimes but more often it didn’t.
                    Would say something like 1 out of 5 I got a reload dialog
                    after manually reloading the file.

                    I dug through the source to understand what is going on.
                    What happens is that npp uses ReadDirectoryChangesW
                    to get the notification when a file gets changed and in addition
                    it uses a “manual” trigger NPPM_INTERNAL_CHECKDOCSTATUS once npp regains the focus
                    and some mechanism, I haven’t found so far, when a different
                    buffer gets activated.

                    Using ReadDirectoryChangesW:
                    It does this to prevent the app to constantly poll each file open
                    but unfortunately MS implemented it in a way where it is possible
                    to either loose such events or not to get informed at all.
                    I cannot say if this makes sense or not what MS did, but that is how it is done.
                    From my point of view it makes sense to use this api, with the
                    limitation that you rely on the file to be written in a certain way to
                    receive the notifications. FastIoWrite, used by ping, doesn’t seem to
                    trigger this events.

                    I did some test with this python script

                    import time
                    
                    print('start')
                    with open(r'd:\ping.txt', 'w+') as f:
                        for i in range(10):
                            print(f'{i}')
                            f.write('test\n')
                            f.flush()
                            time.sleep(2)
                    print('done')
                    

                    in order to see if I can get when a reload dialog happens and when not
                    but the result was, that there was dialog opened at all when reloading the file.
                    Which on the other side makes me believe, that the reload dialog
                    seems to be triggered but something else.

                    Personally I would vote for an additional feature which implements
                    polling a file constantly. Once you’ve discovered that a certain file is
                    not updated you would switch to to a polling monitoring.

                    1 Reply Last reply Reply Quote 3
                    • Michi KaaM
                      Michi Kaa
                      last edited by

                      Interesting, thanks for the investigastion. From my experience it feels like something with getting the focus back to the file. as if “Ctrl+R” is leading to have the focus on the current file lost, after the reload it is regained. When the focus is regained, the check for modification kicks in and if the file was modified in the mean time, it asks if the file should be reloaded. If the focus is lost, maybe it is possible to reload with Ctrl+R without having the focus lost?

                      Reading your posting reminded me on the first posting in this thread and the sidenote: since “Monitoring tail -f” doesn’t work as I expect it.

                      The “eye-button” also known as since “Monitoring tail -f” would solve this issue, if it worked as I’d expect it. I experience the same as here: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4955

                      1 Reply Last reply Reply Quote 1
                      • First post
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors