Sublime Forum

Is there a robust way to trigger an event when a file is reloaded?

#1

When a file is reloaded, either because it changed on disk or because the user does something like a revert, I would like to trigger an event. I have a ViewEventListener that works for other events, but I can’t get an event to trigger in this instance.

Given that there is no on_reload() event, one would expect that on_load() may be called again or even on_close()/on_load(), but it is not.

I find that on_modified() works unless the view is read-only and the file changes on disk (causing a reload). In that case, I can’t find any of the ViewEventListener events that trigger. Unfortunately, that’s the case I care about. I’m using sublime to analyze a log file that I don’t want to edit, but it may change on disk.

0 Likes