Skip to content

Commit

Permalink
Merge pull request #44 from plutonium-239/master
Browse files Browse the repository at this point in the history
  • Loading branch information
TerminalFi authored Feb 10, 2025
2 parents 5fe214f + 33121de commit 0fdd604
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions colored_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,27 +123,26 @@ def open_scheme(self, scheme_path):
class ColoredCommentsEventListener(sublime_plugin.EventListener):
def on_init(self, views):
for view in views:
view.run_command("colored_comments")
if (window := view.window()) is not None:
window.run_command("colored_comments")

def on_load_async(self, view):
view.run_command("colored_comments")
if (window := view.window()) is not None:
window.run_command("colored_comments")

def on_modified_async(self, view):
view.run_command("colored_comments")
if (window := view.window()) is not None:
window.run_command("colored_comments")


class ColoredCommentsCommand(sublime_plugin.TextCommand):
def run(self, edit):
class ColoredCommentsCommand(sublime_plugin.WindowCommand):
def run(self, vid=None):
self.view = self.window.active_view() if vid is None else sublime.View(vid)
if self.view.settings().get("syntax") in settings.disabled_syntax:
return

# self.ClearDecorations()
self.ApplyDecorations()

def ClearDecorations(self) -> None:
for region_key in settings.region_keys:
self.view.erase_regions(region_key)

def ApplyDecorations(self) -> None:
to_decorate = dict()
prev_match = str()
Expand Down Expand Up @@ -178,10 +177,15 @@ def ApplyDecorations(self) -> None:
)


class ColoredCommentsClearCommand(ColoredCommentsCommand, sublime_plugin.TextCommand):
def run(self, edit):
class ColoredCommentsClearCommand(sublime_plugin.WindowCommand):
def run(self, vid=None):
self.view = self.window.active_view() if vid is None else sublime.View(vid)
self.ClearDecorations()

def ClearDecorations(self) -> None:
for region_key in settings.region_keys:
self.view.erase_regions(region_key)


def plugin_loaded() -> None:
load_settings()
Expand Down

0 comments on commit 0fdd604

Please # to comment.