Skip to content

Commit

Permalink
Merge pull request #13 from scholer/backlog
Browse files Browse the repository at this point in the history
Check is_dirty to prevent invoking auto-save when file is reloaded from disk
  • Loading branch information
James Zhang committed Apr 7, 2015
2 parents 4520ecd + 79044e8 commit 849f397
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions auto_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def on_modified(self, view):
Must use this callback for ST2 compatibility
'''
def callback():
view.run_command("save")
if view.is_dirty() and not view.is_loading():
view.run_command("save")
else:
print("Auto-save callback invoked, but view is",
"currently loading." if view.is_loading() else "unchanged from disk.")


'''
Expand All @@ -44,7 +48,7 @@ def debounce_save():
AutoSaveListener.save_queue = []


if settings.get(on_modified_field) and view.file_name():
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.

Expand Down

0 comments on commit 849f397

Please sign in to comment.