Reputation: 31
I am writing sublime text3 plugin.(python3)
I want to make a WindowCommand which opens files and does somethings on files then saves and closes the views.
However, when I open a file at WindowCommand, view is not opened until the plugin is finished.
It looks like WindowCommand blocks main sublime thread.
So I can't do anything on the opened views.
When I try to wait until the view is opened using 'is_loading()' API, it waits forever because view has not been opened until the command has finished
Anyone can give any tips or solution?
Thank you
Upvotes: 2
Views: 1079
Reputation: 19754
If the plugin is opening, editing, saving, and closing plugins, why not just write to the file. It would save you the overhead of managing all the views. Anyways, you will need to do some threading. Take a look at http://net.tutsplus.com/tutorials/python-tutorials/how-to-create-a-sublime-text-2-plugin/. It's written for ST2, but the same concepts apply, though the libraries changed between python2 and python 3. Step 4 begins talking about threading.
Upvotes: 1