Skip to content

Commit

Permalink
updates closecftag command, hopefully solves some issues here
Browse files Browse the repository at this point in the history
  • Loading branch information
atomi committed Sep 16, 2013
1 parent 7ac2267 commit b2ed2a4
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions coldfusion-plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def run(self, edit):

# insert the ">" char
for region in self.view.sel():
self.view.insert(edit, region.end(), ">")
self.view.insert(edit, region.b, ">")

# return if disabled in ColdFusion.sublime-settings file
if not s.get("auto_close_cfml"):
Expand All @@ -124,21 +124,33 @@ def run(self, edit):
# prevents triggering inside strings and other scopes that are not block tags
# this should be taken care of in keybindings, but it's not working for cfcomponent
# TODO ST3: use scope_selector or clean this out it may work through keybindings now
if self.view.match_selector(pos, "string") \
or self.view.match_selector(pos, "source.cfscript.embedded.cfml") \
or not self.view.match_selector(pos, "meta.tag.block.cf"):
return

# only close tag if it's a block tag
if self.view.match_selector(pos,"meta.tag.block.cf") \
and not self.view.substr(pos - 1) == "/": # don't close an already closed tag
# cursor position
# pos = self.view.sel()[0].b
# if self.view.match_selector(pos, "string") \
# or self.view.match_selector(pos, "source.cfscript.embedded.cfml") \
# or not self.view.match_selector(pos, "meta.tag.block.cf"):
# return

if self.view.match_selector(region.b - 1,"meta.tag.block.cf") \
and not self.view.substr(region.b - 2) == "/": # don't close an already closed tag


for temp in self.view.sel():
tag_name = dic.get_tag_name(self.view, temp.b)
indent = not s.get("auto_indent_on_close") or tag_name == "cfoutput"
if not indent:
self.view.insert(edit,temp.b,"\n\t\n</" + tag_name + ">")
else:
self.view.insert(edit, temp.b, "</" + tag_name + ">")

self.view.run_command("move", {"by": "lines", "forward": False})

tagname = dic.get_tag_name(self.view, pos) + ">"
# if not s.get("auto_indent_on_close") or tag_name == "cfoutput":
# self.view.run_command("insert_snippet", {"contents": "$0</" + tag_name + ">"})
# else:
# self.view.run_command("insert_snippet", {"contents": "\n\t$0\n</" + get_current_name() + ">"})

if not s.get("auto_indent_on_close") or tagname == "cfoutput>":
self.view.run_command("insert_snippet", {"contents": "$0</" + tagname})
else:
self.view.run_command("insert_snippet", {"contents": "\n\t$0\n</" + tagname})
return None

# *****************************************************************************************
Expand Down

0 comments on commit b2ed2a4

Please sign in to comment.