You would do one of two things:
- Implement an
ViewEventListener and listen for the
on_load() event; when the event is raised, the file is loaded, and then you do what you want.
- Poll in a non-blocking manner
The first one is the recommended way, but it requires you to structure your code in a way that allows you to know, when an
on_load event is raised, that it’s a file that you need to do something with.
For a more traditional route:
sublime.set_timeout(lambda: do_something_with_loaded_file(view), 250)
print('The file has loaded and now I am doing things with it
view = window.open_file('some_filename.txt')
Now the function
do_something_with_loaded_file() will either schedule itself to be called again in a short while if the file is not loaded OR do something if it has; it will keep calling itself until eventually the file loads.
That said to do this you need to have some extra function that can take the action, and if you can do that you can probably use an
on_load event too.