Sublime Forum

ViewEventListener.on_post_save never called

#1

Several of the ViewEventListener methods do not appear to ever get called, despite being advertised in the Sublime3 API. For me, the most important is on_post_save (although, on_new and on_load would also be helpful.) Example code:

class MyViewEventListener(sublime_plugin.ViewEventListener):
    @classmethod
    def is_applicable(cls, settings):
        return True


    @classmethod
    def applies_to_primary_view_only(cls):
        return False

    def on_post_save(self):
        print('on_post_save called!!!!')

The console window never prints on_post_save called!!!!. Broken in Build 3143 and development, Mac OS X (probably platform-independent.)

0 Likes

#2

it won’t work in build 3143 because it was only added in 3155, check https://www.sublimetext.com/3dev

0 Likes

#3

That explains a few things. Probably a good idea to identify which parts of the “expanded” API correspond to which ST3 version. Because, as things stand, it’s not clear which parts of ViewEventListener are actually usable in 3146, which most of my users use, vice current development build.

0 Likes

#4

BTW: I would never have known that on_post_save was added from the 3155 bullet list: “API: Expanded ViewEventListener API”.

0 Likes

#5

there’s an unofficial “official ST documentation change tracker” here which can help to know roughly when APIs were added and then guess what build it corresponds to:

2 Likes

#6

Really, truly, honestly: ST3 needs to do API version labeling. I can write decorators that allow me to work around versions or ensure downward plugin compatibility. Surprises aren’t kosher.

1 Like

#7

hopefully SublimeHQ will make the official docs open source soon so we can make PRs that suggest how version labelling could look like :slight_smile:

1 Like