From fd69613832f291b8aa5fef5dc6ef3ce3f947e5a5 Mon Sep 17 00:00:00 2001 From: Nikolajus Date: Wed, 19 Jun 2013 12:43:39 +0200 Subject: [PATCH] Issue #22 change syntax only if json object was prettified --- PrettyJson.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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]