Don't allow :s delimiters not allowed by vim

"Instead of the '/' which surrounds the pattern and replacement string,
you can use any other single-byte character, but not an alphanumeric
character, '\', '"'' or '|'."
- http://vimdoc.sourceforge.net/htmldoc/change.html#:substitute
This commit is contained in:
Jacob Wahlgren 2015-09-22 00:35:36 +02:00
parent 728ccaa5f9
commit e2841dc26c
2 changed files with 10 additions and 3 deletions

View file

@ -199,9 +199,9 @@ class Ex
substitute: (range, args) ->
args = args.trimLeft()
delim = args[0]
if /[a-z]/i.test(delim)
if /[a-z1-9\\"|]/i.test(delim)
throw new CommandError(
"Regular expressions can't be delimited by letters")
"Regular expressions can't be delimited by alphanumeric characters, '\\', '\"' or '|'")
delimRE = new RegExp("[^\\\\]#{delim}")
spl = []
args_ = args[1..]