Dotfiles/sublime-text/Default/save_on_focus_lost.py

11 lines
435 B
Python
Raw Normal View History

2014-05-12 18:57:15 +02:00
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');