diff --git a/PrettyJson.py b/PrettyJson.py index dc6a0f3..8899fc9 100644 --- a/PrettyJson.py +++ b/PrettyJson.py @@ -20,10 +20,13 @@ class PrettyjsonCommand(sublime_plugin.TextCommand): """ def run(self, edit): for region in self.view.sel(): + + selected_entire_file = False + # If no selection, use the entire file as the selection if region.empty() and s.get("use_entire_file_if_no_selection", True): selection = sublime.Region(0, self.view.size()) - self.change_syntax() + selected_entire_file = True else: selection = region @@ -39,6 +42,9 @@ class PrettyjsonCommand(sublime_plugin.TextCommand): separators=(',', ': '), use_decimal=True)) + if selected_entire_file: + self.change_syntax() + except Exception: import sys exc = sys.exc_info()[1]