Issue #22 change syntax only if json object was prettified

This commit is contained in:
Nikolajus 2013-06-19 12:43:39 +02:00 committed by Nikolajus Krauklis
parent 5bf0c1f16d
commit fd69613832
1 changed files with 7 additions and 1 deletions

View File

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