Skip to content

Commit

Permalink
Merge pull request #17 from scholer/early_abort_optimization
Browse files Browse the repository at this point in the history
Move check determining if auto save should fire to the top of on_modified
  • Loading branch information
James Zhang committed Jun 19, 2015
2 parents 3ad13f7 + c313e50 commit a1f3251
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions auto_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class AutoSaveListener(sublime_plugin.EventListener):

def on_modified(self, view):
settings = sublime.load_settings(settings_filename)
if not (settings.get(on_modified_field) and view.file_name() and view.is_dirty()):
return

delay = settings.get(delay_field)


Expand All @@ -48,9 +51,8 @@ def debounce_save():
AutoSaveListener.save_queue = []


if settings.get(on_modified_field) and view.file_name() and view.is_dirty():
AutoSaveListener.save_queue.append(0) # Append to queue for every on_modified event.
Timer(delay, debounce_save).start() # Debounce save by the specified delay.
AutoSaveListener.save_queue.append(0) # Append to queue for every on_modified event.
Timer(delay, debounce_save).start() # Debounce save by the specified delay.


class AutoSaveCommand(sublime_plugin.TextCommand):
Expand Down

0 comments on commit a1f3251

Please sign in to comment.