simple regex just for line number, and some logic to highlight line above

This commit is contained in:
Nikolajus 2016-07-15 00:19:32 +02:00
parent 04296b2d13
commit b3066c8014
1 changed files with 7 additions and 1 deletions

View File

@ -53,7 +53,7 @@ s = sublime.load_settings("Pretty JSON.sublime-settings")
class PrettyJsonBaseCommand(sublime_plugin.TextCommand):
json_error_matcher = re.compile(r"line (\d+) column (\d+) \(char (\d+)\)")
json_error_matcher = re.compile(r"line (\d+)")
force_sorting = False
@staticmethod
@ -116,6 +116,12 @@ class PrettyJsonBaseCommand(sublime_plugin.TextCommand):
m = self.json_error_matcher.search(message)
if m:
line = int(m.group(1)) - 1
# sometime we need to highlight one line above
if ("','" in message and "delimiter" in message) \
or "control character '\\n'" in message:
line -= 1
regions = [self.view.full_line(self.view.text_point(line, 0)), ]
self.view.add_regions('json_errors', regions, 'invalid', 'dot',
sublime.DRAW_OUTLINED)