-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.py
21 lines (15 loc) · 843 Bytes
/
commands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import sublime
import sublime_plugin
from .lib.comment_settings import CommentSettings
from .lib.view_verifier import ViewVerifier
class MagicCommentInsertCommand(sublime_plugin.TextCommand):
def run(self, edit):
settings = sublime.load_settings("MagicComment.sublime-settings")
for raw_comment_settings in settings.get("comments", []):
comment_settings = CommentSettings(raw_comment_settings)
if ViewVerifier(self.view, comment_settings).should_run():
self.__insert_comment(edit, comment_settings)
def __insert_comment(self, edit, comment_settings):
line_number = self.view.text_point(comment_settings.line() - 1, 0)
comment_text = comment_settings.text() + ("\n" * comment_settings.blank_lines())
self.view.insert(edit, line_number, comment_text)