Skip to content

Commit

Permalink
addresses #5, better handles tag commands with multiple cursors active
Browse files Browse the repository at this point in the history
  • Loading branch information
jcberquist committed Jan 19, 2016
1 parent bb5cc7e commit 34ebe65
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions cfml_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ def on_query_completions(self, view, prefix, locations):
class CloseCfmlTagCommand(sublime_plugin.TextCommand):

def run(self, edit):
pt = self.view.sel()[0].begin()
cfml_only = self.view.match_selector(pt, "string")
last_open_tag = utils.get_last_open_tag(self.view,pt - 1, cfml_only)
if last_open_tag:
self.view.insert(edit,pt,"/" + last_open_tag + ">")
else:
# if there is no open tag print "/"
self.view.insert(edit,pt,"/")
for sel in self.view.sel():
pt = sel.begin()
cfml_only = self.view.match_selector(pt, "string")
last_open_tag = utils.get_last_open_tag(self.view,pt - 1, cfml_only)
if last_open_tag:
self.view.insert(edit,pt,"/" + last_open_tag + ">")
else:
# if there is no open tag print "/"
self.view.insert(edit,pt,"/")

class CfmlAutoInsertClosingTagCommand(sublime_plugin.TextCommand):

Expand All @@ -74,7 +75,7 @@ def run(self, edit):
if next_char != tag_close_search_region.begin():
self.view.run_command("insert_snippet", {"contents": ">$0</" + tag_name + ">"})
return
self.view.insert(edit,pt,">")
self.view.run_command("insert_snippet", {"contents": ">"})

class CfmlBetweenTagPairCommand(sublime_plugin.TextCommand):

Expand All @@ -84,7 +85,7 @@ def run(self, edit):
if cfml_between_tag_pair in ["newline","indent"] and utils.between_cfml_tag_pair(self.view, pt):
self.view.run_command("insert_snippet", {"contents": "\n" + ("\t" if cfml_between_tag_pair == "indent" else "") + "$0\n"})
return
self.view.insert(edit,pt,"\n")
self.view.run_command("insert_snippet", {"contents": "\n"})

class CfmlDefaultPackageSettingsCommand(sublime_plugin.WindowCommand):

Expand Down

0 comments on commit 34ebe65

Please sign in to comment.