Fix bug in python snipmate conversion script, to avoid skipping every other snippet

This commit is contained in:
Giuseppe Rota 2012-02-05 18:40:58 +01:00 committed by Holger Rapp
parent 6d79810efb
commit 85832c1b25

View File

@ -48,7 +48,15 @@ def convert_snippet_file(source):
# In snippet: Check if indentation level is the same. If not, snippet has ended # In snippet: Check if indentation level is the same. If not, snippet has ended
if line[:len(whitespace)] != whitespace: if line[:len(whitespace)] != whitespace:
retval += convert_snippet_contents(snippet) + "endsnippet\n\n" retval += convert_snippet_contents(snippet) + "endsnippet\n\n"
state = 0 # Copy-paste the section from state=0 so that we don't skip every other snippet
if line[:8] == "snippet ":
snippet_info = re.match("(\S+)\s*(.*)", line[8:])
if not snippet_info:
print >> sys.stderr, "Warning: Malformed snippet\n %s\n" % line
continue
retval += 'snippet %s "%s"' % (snippet_info.group(1), snippet_info.group(2) if snippet_info.group(2) else snippet_info.group(1)) + "\n"
state = 1
snippet = ""
else: else:
snippet += line[len(whitespace):] snippet += line[len(whitespace):]
if state == 2: if state == 2: