Skip to content

Commit

Permalink
Reloading project settings on_pre_save if the project file changed
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfarsinsen committed Nov 8, 2013
1 parent 4255eb1 commit e4e3e85
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions phpcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,3 +679,25 @@ def on_selection_modified(self, view):
cmd = PhpcsCommand.instance(view, False)
if isinstance(cmd, PhpcsCommand):
cmd.set_status_bar()

def on_pre_save(self, view):
current_project_file = sublime.active_window().project_file_name();

if current_project_file == None:
debug_message('Skipping config reload because no project file is loaded')
return

if hasattr(pref, 'last_project_file'):
last_project_file = pref.last_project_file
else:
last_project_file = None

debug_message('Current project file: ' + str(current_project_file));
debug_message('Last project file: ' + str(last_project_file));

if last_project_file == current_project_file:
debug_message('Skipping reload. Project file did not change')
else:
debug_message('Reloading config because the project changed')
pref.load();
setattr(pref, 'last_project_file', current_project_file)

0 comments on commit e4e3e85

Please sign in to comment.