Skip to content

Commit

Permalink
If something is selected, replace the selection with the closing tag
Browse files Browse the repository at this point in the history
  • Loading branch information
titoBouzout committed Mar 4, 2012
1 parent 38b32ad commit 020a2bd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tag_close_tag_on_slash.py
Expand Up @@ -21,10 +21,19 @@ def run(self, edit):

if '<' == previousCharacter:
tag = self.close_tag(view.substr(sublime.Region(0, cursorPosition)))
view.insert(edit, cursorPosition, tag);
if region.empty():
replace = False
view.insert(edit, cursorPosition, tag);
else:
replace = True
view.replace(edit, sublime.Region(region.begin(), region.end()), '');
view.insert(edit, cursorPosition, tag);
if tag != '/':
closed_some_tag = True
new_selections_insert.append(sublime.Region(region.end()+len(tag), region.end()+len(tag)))
if replace:
new_selections_insert.append(sublime.Region(region.begin()+len(tag), region.begin()+len(tag)))
else:
new_selections_insert.append(sublime.Region(region.end()+len(tag), region.end()+len(tag)))
else:
new_selections.append(sublime.Region(region.end()+len(tag), region.end()+len(tag)))
else:
Expand Down

0 comments on commit 020a2bd

Please sign in to comment.