Skip to content

Commit

Permalink
Merge pull request #184 from deathaxe/fix/event-listener
Browse files Browse the repository at this point in the history
fix PrettyJsonLintListener
  • Loading branch information
TerminalFi authored Aug 7, 2024
2 parents eef27b8 + f7800eb commit 382534a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions PrettyJsonListeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
s = sublime.load_settings("Pretty JSON.sublime-settings")


class PrettyJsonLintListener(sublime_plugin.EventListener, PrettyJsonBaseCommand):
def on_post_save(self, view):
class PrettyJsonLintListener(sublime_plugin.ViewEventListener, PrettyJsonBaseCommand):
def on_post_save(self):
if not s.get("validate_on_save", True):
return

as_json = s.get("as_json", ["JSON"])
if any(syntax in view.settings().get("syntax") for syntax in as_json):
view_syntax = self.view.settings().get("syntax")
if any(syntax in view_syntax for syntax in as_json):
self.clear_phantoms()
json_content = view.substr(sublime.Region(0, view.size()))
json_content = self.view.substr(sublime.Region(0, self.view.size()))
try:
self.json_loads(json_content)
except Exception as ex:
Expand All @@ -27,5 +28,6 @@ def on_pre_save(self, view):
return

as_json = s.get("as_json", ["JSON"])
if any(syntax in view.settings().get("syntax") for syntax in as_json):
view_syntax = view.settings().get("syntax")
if any(syntax in view_syntax for syntax in as_json):
view.run_command("pretty_json")

0 comments on commit 382534a

Please sign in to comment.