Hello
I’ve battled through the documentation, which in places is just plain wrong, and examples (ditto for them!) and the fact that I’m only just learning Python in order to create my first plug-in. What I want is for Sublime to work like just about every other application I have and open new documents (or opening existing documents) in a tab to the rightmost. So I have the following plug-in code:
[code]import sublime, sublime_plugin
class EventDump(sublime_plugin.EventListener):
def on_new(self, view):
print ("new file")
print (view.window().__class__)
w = view.window()
w.set_view_index(view, w.active_group(), len(w.views_in_group(w.active_group())) - 1)[/code]
If you have the console window open, you will see that there is an error. If, however, you change the ‘on_new’ method to be ‘on_pre_save’ and then save the document (and again, after the plug-in has been loaded), it works. It appears that the new view isn’t being given a window until after the on_new method fires. Obviously, this isn’t much good to me!
Does anyone have any ideas how to get round this? It works for ‘on_load’ for existing documents, but just not for new ones.
Also, there is a bug with the document overview on the right - if you have some text with long lines (word wrap off) and scroll right, the white box around the document outline (if you have that enabled) scrolls off to the right, out of view. Now if you scroll down the document in the document overview thingy, it resets your horizontal scroll position to leftmost. This is incredibly irritating!
Cheers
Aaron