From e4e3e85616ec167c7b9e787cb08f62877629e4e1 Mon Sep 17 00:00:00 2001 From: Peter Farsinsen Date: Fri, 8 Nov 2013 11:12:18 +0100 Subject: [PATCH] Reloading project settings on_pre_save if the project file changed --- phpcs.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/phpcs.py b/phpcs.py index e4f89c0..f1995c7 100644 --- a/phpcs.py +++ b/phpcs.py @@ -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) \ No newline at end of file