config/sublime/Packages/Default/save_on_focus_lost.py
2012-08-01 21:04:05 -07:00

10 lines
435 B
Python

import sublime, sublime_plugin
import os.path
class SaveOnFocusLost(sublime_plugin.EventListener):
def on_deactivated(self, view):
# The check for os.path.exists ensures that deleted files won't be resurrected
if (view.file_name() and view.is_dirty() and
view.settings().get('save_on_focus_lost') == True and
os.path.exists(view.file_name())):
view.run_command('save');