Skip to content

Commit

Permalink
Postpone plugin invokation in on_modified event
Browse files Browse the repository at this point in the history
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 98dd39a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion git_gutter_events.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sublime
import sublime_plugin
from view_collection import ViewCollection

Expand All @@ -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)
Expand Down

0 comments on commit 98dd39a

Please sign in to comment.