Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce settings for newly created -> saved files #19

Merged
merged 1 commit into from
Feb 15, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions EditorConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,24 @@
}

class EditorConfig(sublime_plugin.EventListener):
MARKER = 'editorconfig'

def on_activated(self, view):
if view.settings().has('editorconfig'):
return
self.init(view, False)
view.settings().set('editorconfig', True)
if not view.settings().has(self.MARKER):
self.init(view, False)

def on_pre_save(self, view):
self.init(view, True)

def on_post_save(self, view):
if not view.settings().has(self.MARKER):
self.init(view, False)

def init(self, view, pre_save):
path = view.file_name()
if not path:
return

try:
config = get_properties(path)
except EditorConfigError:
Expand Down Expand Up @@ -80,3 +85,5 @@ def apply_config(self, view, config):
settings.set('ensure_newline_at_eof_on_save', True)
elif insert_final_newline == 'false':
settings.set('ensure_newline_at_eof_on_save', False)

view.settings().set(self.MARKER, True)