Notepap++ asks if the file should be reloaded after manual reload
-
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?
-
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.- getting the dialog that there was an update (default) or
- enable silent updating, (no dialog)
Config can be changed in settings->preferences->MISC.
tick or untick Update silently in file status auto-detection -
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. -
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. -
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)
-
@Ekopalypse could you reproce the behaviour? If yes, what do you think? Desired or undesired behaviour? Also happens in v7.8.1 (64-bit)
-
@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.
-
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. -
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