Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
Fix errors about color schemes not being found
Browse files Browse the repository at this point in the history
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
FichteFoll committed May 5, 2013
1 parent 1e515fa commit 9eb3b22
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions inactive_pane.py
Expand Up @@ -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(
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit 9eb3b22

Please sign in to comment.