Escaping of \ didn't work
This commit is contained in:
parent
52438051be
commit
2def1b4ce1
@ -110,19 +110,19 @@ class _CleverReplace(object):
|
|||||||
|
|
||||||
class _TOParser(object):
|
class _TOParser(object):
|
||||||
# A simple tabstop with default value
|
# A simple tabstop with default value
|
||||||
_TABSTOP = re.compile(r'''(?<!\\)\${(\d+)[:}]''')
|
_TABSTOP = re.compile(r'''(?<![^\\]\\)\${(\d+)[:}]''')
|
||||||
# A mirror or a tabstop without default value.
|
# A mirror or a tabstop without default value.
|
||||||
_MIRROR_OR_TS = re.compile(r'(?<!\\)\$(\d+)')
|
_MIRROR_OR_TS = re.compile(r'(?<![^\\]\\)\$(\d+)')
|
||||||
# A mirror or a tabstop without default value.
|
# A mirror or a tabstop without default value.
|
||||||
_TRANSFORMATION = re.compile(r'(?<!\\)\${(\d+)/(.*?)/(.*?)/([a-zA-z]*)}')
|
_TRANSFORMATION = re.compile(r'(?<![^\\]\\)\${(\d+)/(.*?)/(.*?)/([a-zA-z]*)}')
|
||||||
# The beginning of a shell code fragment
|
# The beginning of a shell code fragment
|
||||||
_SHELLCODE = re.compile(r'(?<!\\)`')
|
_SHELLCODE = re.compile(r'(?<![^\\]\\)`')
|
||||||
# The beginning of a python code fragment
|
# The beginning of a python code fragment
|
||||||
_PYTHONCODE = re.compile(r'(?<!\\)`!p')
|
_PYTHONCODE = re.compile(r'(?<![^\\]\\)`!p')
|
||||||
# The beginning of a vimL code fragment
|
# The beginning of a vimL code fragment
|
||||||
_VIMCODE = re.compile(r'(?<!\\)`!v')
|
_VIMCODE = re.compile(r'(?<![^\\]\\)`!v')
|
||||||
# Escaped characters in substrings
|
# Escaped characters in substrings
|
||||||
_UNESCAPE = re.compile(r'\\[`$]')
|
_UNESCAPE = re.compile(r'\\[`$\\]')
|
||||||
|
|
||||||
def __init__(self, parent, val, indent):
|
def __init__(self, parent, val, indent):
|
||||||
self._v = val
|
self._v = val
|
||||||
|
17
test.py
17
test.py
@ -427,6 +427,23 @@ class TabStop_EscapingCharsDollars(_VimTest):
|
|||||||
snippets = ("test", r"snip \$0 $$0 end")
|
snippets = ("test", r"snip \$0 $$0 end")
|
||||||
keys = "test" + EX + "hi"
|
keys = "test" + EX + "hi"
|
||||||
wanted = "snip $0 $hi end"
|
wanted = "snip $0 $hi end"
|
||||||
|
class TabStop_EscapingChars_Backslash(_VimTest):
|
||||||
|
snippets = ("test", r"This \ is a backslash!")
|
||||||
|
keys = "test" + EX
|
||||||
|
wanted = "This \\ is a backslash!"
|
||||||
|
class TabStop_EscapingChars_Backslash2(_VimTest):
|
||||||
|
snippets = ("test", r"This is a backslash \\ done")
|
||||||
|
keys = "test" + EX
|
||||||
|
wanted = r"This is a backslash \ done"
|
||||||
|
class TabStop_EscapingChars_Backslash3(_VimTest):
|
||||||
|
snippets = ("test", r"These are two backslashes \\\\ done")
|
||||||
|
keys = "test" + EX
|
||||||
|
wanted = r"These are two backslashes \\ done"
|
||||||
|
class TabStop_EscapingChars_Backslash4(_VimTest):
|
||||||
|
# Test for bug 746446
|
||||||
|
snippets = ("test", r"\\$1{$2}")
|
||||||
|
keys = "test" + EX + "hello" + JF + "world"
|
||||||
|
wanted = r"\hello{world}"
|
||||||
class TabStop_EscapingChars_RealLife(_VimTest):
|
class TabStop_EscapingChars_RealLife(_VimTest):
|
||||||
snippets = ("test", r"usage: \`basename \$0\` ${1:args}")
|
snippets = ("test", r"usage: \`basename \$0\` ${1:args}")
|
||||||
keys = "test" + EX + "[ -u -v -d ]"
|
keys = "test" + EX + "[ -u -v -d ]"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user