Skip to content
Browse files

Fix errors about color schemes not being found

Because Sublime Text (2) calls `on_activated` when a plugin was loaded for ALL
views, including widgets and some invisible views or something there were way
more calls then necessary. Widgets were detected by the 'is_widget' setting but
the invisible "void views" could not and thus the dimmed scheme ended up being
assigned to them. However, when deactivating the plugin it would not iterate
over these invisible views resulting in errors when deactivating (or when
restarting and thus removing the scheme file in the process).

See: http://www.sublimetext.com/forum/viewtopic.php?f=6&t=11716&p=48146#p48146
  • Loading branch information...
1 parent 1e515fa commit 9eb3b223fda21111237e4dcf4fe9fe1761688d72 @FichteFoll FichteFoll committed May 5, 2013
Showing with 10 additions and 0 deletions.
  1. +10 −0 inactive_pane.py
View
10 inactive_pane.py
@@ -83,6 +83,7 @@ class InactivePanes(object):
Maybe I can think of a better way to structure plugins like these but for now this'll do it
"""
_settings = None
+ _refreshed = False
def init(self):
self._settings = Settings(
@@ -129,6 +130,8 @@ def onerror(function, path, excinfo):
self.refresh_views()
def refresh_views(self, disable=False):
+ # We need this because ST for some reason calls on_activated with void views on startup
+ self._refreshed = True
active_view_id = sublime.active_window().active_view().id()
for window in sublime.windows():
for v in window.views():
@@ -211,6 +214,13 @@ def dim_rgb(match):
# The actual event handlers
def on_activated(self, view):
+ if not self._refreshed:
+ # No business here, we wait for the plugin to refresh in order to ignore ST2's dummy
+ # views that are passed sometimes.
+ return
+ if not view.file_name() and not view.is_scratch() and not view.is_dirty():
+ print("[%s] What do we have here? A new and empty buffer?")
+
vsettings = view.settings()
# Get the previous scheme of the current view (if it existed).

0 comments on commit 9eb3b22

Please sign in to comment.
Something went wrong with that request. Please try again.