In my plugin, I’m attempting to open a file in the current project as follows:
class NotWorkingCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view.window().open_file(os.path.join(os.path.cwd(), "test.txt"))
print view.size()
The file opens correctly, however view.size() returns 0 for this returned view object, as does sublime.active_window().active_view().size(). Any idea what could be going wrong?
Edit - If the file is already open, then it works as expected. So it looks like size() is zero because the view object is still being initialize (or something like that). Could someone please point me towards how I could add a callback or listener that would be triggered once the view has fully loaded? I don’t think I can use on_load as-is, because I need to jump to a particular line after loading the file, and that would have to be passed as an argument to the callback.
Edit 2 - view.is_loading()