Permalink
Browse files

Postpone plugin invokation in on_modified event

If plugin in on_modified event takes more than 0.02 sec user gets a
warning. This commit makes plugin actually do its job in next event
loop cycle.
  • Loading branch information...
frantic committed Dec 19, 2012
1 parent 2ea3712 commit 98dd39ac261c422af9c254ba92efa1a2cd0458d7
Showing with 6 additions and 1 deletion.
  1. +6 −1 git_gutter_events.py
View
@@ -1,3 +1,4 @@
+import sublime
import sublime_plugin
from view_collection import ViewCollection
@@ -8,7 +9,11 @@ def on_load(self, view):
def on_modified(self, view):
if view.settings().get('git_gutter_live_mode', True):
- ViewCollection.add(view)
+ # Sublime Text is very strict on the amount of time plugin
+ # uses in performance-critical events. Sometimes invoking plugin
+ # from this event causes Sublime warning to appear, so we need to
+ # schedule its run for future.
+ sublime.set_timeout(lambda: ViewCollection.add(view), 1)
def on_clone(self, view):
ViewCollection.add(view)

0 comments on commit 98dd39a

Please sign in to comment.