Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor tweaks in Python version of ZC and TextMate bundle

  • Loading branch information...
commit e5100bb97a358156a093835075d9d761acfa43f0 1 parent 1e46cb4
@sergeche sergeche authored
View
18 plugins/TextMate/Zen Coding.tmbundle/Support/expand_abbreviation.py
@@ -23,10 +23,18 @@
line = cur_line[0:cur_index]
abbr = zencoding.utils.extract_abbreviation(line)
+
+output = zencoding.utils.escape_text(line) + '$0' + zencoding.utils.escape_text(cur_line[cur_index:])
+
if abbr:
- result = line[0:-len(abbr)] + zencoding.expand_abbreviation(abbr, editor.get_syntax(), editor.get_profile_name())
- cur_line_pad = re.match(r'^(\s+)', cur_line)
- if cur_line_pad:
- result = zencoding.utils.pad_string(result, cur_line_pad.group(1))
+ try:
+ result = line[0:-len(abbr)] + zencoding.expand_abbreviation(abbr, editor.get_syntax(), editor.get_profile_name())
+ cur_line_pad = re.match(r'^(\s+)', cur_line)
+ if cur_line_pad:
+ result = zencoding.utils.pad_string(result, cur_line_pad.group(1))
- sys.stdout.write(editor.add_placeholders(result) + zencoding.utils.escape_text(cur_line[cur_index:]))
+ output = editor.add_placeholders(result) + zencoding.utils.escape_text(cur_line[cur_index:])
+ except:
+ pass
+
+sys.stdout.write(output)
View
2  python/zencoding/utils.py
@@ -474,7 +474,7 @@ def extract_abbreviation(text):
start_index = cur_offset + 1
break
- if start_index != -1 and text_count == 0 and brace_count == 0 and group_count == 0:
+ if start_index != -1 and start_index < len(text) and text_count == brace_count == group_count == 0:
return text[start_index:]
else:
return ''
Please sign in to comment.
Something went wrong with that request. Please try again.