Sublime Forum

Make any SEMI_TRANSIENT view smaller

#1

Hello,
I often use the ctrl+alt+enter combination to quickly open a file in a side-by-side / SEMI_TRANSIENT view. E.g. I implicitly do this when using LSP, to quickly see an object definition. Because the horizontal space in the SEMI_TRANSIENT view is limited, I am using this code to remove UI elements from it and save space (I even decrease the font size):

class ResizeView(sublime_plugin.ViewEventListener):
    def on_load_async(self):
        view = self.view
        if view.sheet().is_semi_transient():
            view.settings().set("line_numbers", False)
            view.settings().set("gutter", False)
            view.settings().set("draw_centered", True)
            view.settings().set("wrap_width", 80)
            view.settings().set("word_wrap", True)
            view.settings().set("scroll_past_end", True)            
            view.settings().set("font_size", view.settings().get("font_size") - 1)

This works fine as long as the file is not open already. If the file is already open in a tab, on_load_async event is not triggered. The only handler which intercepts the new SEMI_TRANSIENT view in that case seems to be on_activated(), but at that point the view is no longer reported as semi transient (is_semi_transient() == False).

Any suggestion on how I could intercept all SEMI_TRANSIENT view events? I tried on_clone() and also made ViewEventListener.applies_to_primary_view_only() return False with no luck.

1 Like