Skip to content

Commit

Permalink
-Remove debug code
Browse files Browse the repository at this point in the history
-Let edit events be taken care of by background thread
-Add some comments
  • Loading branch information
facelessuser committed Mar 12, 2012
1 parent 10a9696 commit 8f49531
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions BracketHighlighter.py
Expand Up @@ -836,6 +836,9 @@ def string_scout_right(self, scout, limit):


class BracketHighlighterListenerCommand(sublime_plugin.EventListener):
# Manage when to kick off bracket matching.
# Try and reduce redundant requests by letting the
# background thread ensure certain needed match occurs
def on_load(self, view):
if view.settings().get('is_widget'):
return
Expand All @@ -845,13 +848,9 @@ def on_load(self, view):
def on_modified(self, view):
if view.settings().get('is_widget'):
return
now = time()
Pref.type = BH_MATCH_TYPE_EDIT
if time() - Pref.time > Pref.wait_time:
sublime.set_timeout(lambda: bh_run(), 0)
else:
Pref.modified = True
Pref.time = now
Pref.modified = True
Pref.time = time()

def on_activated(self, view):
if view.settings().get('is_widget'):
Expand All @@ -872,15 +871,18 @@ def on_selection_modified(self, view):
Pref.time = now


# Kick off matching of brackets
def bh_run():
Pref.modified = False
window = sublime.active_window()
view = window.active_view() if window != None else None
bh_match(view, True if Pref.type == BH_MATCH_TYPE_EDIT else False)
print "run"
Pref.time = time()


# Start thread that will ensure highlighting happens after a barage of events
# Initial highlight is instant, but subsequent events in close succession will
# be ignored and then accounted for with one match by this thread
def bh_loop():
while True:
if Pref.modified == True and time() - Pref.time > Pref.wait_time:
Expand Down

0 comments on commit 8f49531

Please sign in to comment.