Sublime Forum

Filewatcher - Option to reload externally modified file

#1

If I’m editing a file and it’s modified by another application, it would be nice if SublimeText would notify me of this and ask me to either save my edits or discard them and load the modified file. Several other editors like Notepad++, Ultraedit and gedit (Linux) have had this “filewatcher” feature for a while. I think the way the Windows apps do this is by handling the WM_ACTIVATE message or using a timer, then just check the date of the of the original file against the date of the last write. If it’s newer then popup a YESNO message box prompting the user to load the external changes.

0 Likes

#2

This is the normal behavior: if you modified the file in sublime you get a message box asking if you want to reload file or keep as is, and if you did not the file is silently reloaded. You can always cancel the change using undo.

0 Likes

#3

Ok, you’re right. But today at work I had a file open in SublimeText on Windows and the same File open in SublimeText on Linux via a shared drive. And when I modified and saved it on either machine, the update was not recognized. I’ll try it again, thanks.

0 Likes

#4

For file on a shared folder behavior can be less consistent, with modification not being seen, or at least with noticeable delay. Not sure if this is an issue with Sublime or a more general issue with the OS …

0 Likes

#5

I believe this is an issue with the os because I have seen similar issues with files not reloading on other applications. I am only speaking from experience using windows with network shares.In our environment we might update the file by merging code changes into our file via version control and sometimes sublime will not recognize the file has changed. I have seen similar issues with visual studio so I am not sure if windows is caching the file info to try to be as efficient as possible.

I have tried to implement my own solution to check if the file has changed and present a prompt to revert the file. Problem I am running into now is that sometimes I get the built in sublime prompt to reload the file which is then followed by my custom prompt, and sometimes I just get my custom prompt. There is no rhyme or reason that I can see. I do have the always prompt to reload setting enabled so I will get the prompt if sublime tried to reload the file.

I case someone has any ideas or can build on what I have, I store the md5 of the view on_deactivate using a custom cache object I created, then check the md5 for the file on disk when the view is activated to see if anything has changed. If they are different I throw the prompt. When the sublime prompt displays it is alway before my custom prompt.

0 Likes