From 36fbf97a8ee7abde584b22d5ffeee1956878168f Mon Sep 17 00:00:00 2001 From: Predrag Date: Tue, 3 Jul 2018 14:42:07 +0200 Subject: [PATCH] Check if the command should run --- SublimePhpCsFixer.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SublimePhpCsFixer.py b/SublimePhpCsFixer.py index ed391e1..2a98c74 100644 --- a/SublimePhpCsFixer.py +++ b/SublimePhpCsFixer.py @@ -209,6 +209,9 @@ def get_project_folder(file): class SublimePhpCsFixCommand(sublime_plugin.TextCommand): + def is_enabled(self): + return self.is_supported_scope(self.view) + def run(self, edit): try: log_to_console("Formatting view...") @@ -227,6 +230,9 @@ def run(self, edit): except ExecutableNotFoundException as e: log_to_console(str(e)) + def is_supported_scope(self, view): + return 'embedding.php' in view.scope_name(self.view.sel()[0].begin()) + class SublimePhpCsFixListener(sublime_plugin.EventListener): def on_pre_save(self, view):