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:
parent
728ccaa5f9
commit
e2841dc26c
2 changed files with 10 additions and 3 deletions
|
|
@ -199,9 +199,9 @@ class Ex
|
||||||
substitute: (range, args) ->
|
substitute: (range, args) ->
|
||||||
args = args.trimLeft()
|
args = args.trimLeft()
|
||||||
delim = args[0]
|
delim = args[0]
|
||||||
if /[a-z]/i.test(delim)
|
if /[a-z1-9\\"|]/i.test(delim)
|
||||||
throw new CommandError(
|
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}")
|
delimRE = new RegExp("[^\\\\]#{delim}")
|
||||||
spl = []
|
spl = []
|
||||||
args_ = args[1..]
|
args_ = args[1..]
|
||||||
|
|
|
||||||
|
|
@ -453,7 +453,14 @@ describe "the commands", ->
|
||||||
keydown(':')
|
keydown(':')
|
||||||
submitNormalModeInputText(':substitute nanxngi')
|
submitNormalModeInputText(':substitute nanxngi')
|
||||||
expect(atom.notifications.notifications[0].message).toEqual(
|
expect(atom.notifications.notifications[0].message).toEqual(
|
||||||
"Command error: Regular expressions can't be delimited by letters")
|
"Command error: Regular expressions can't be delimited by alphanumeric characters, '\\', '\"' or '|'")
|
||||||
|
expect(editor.getText()).toEqual('abcaABC\ndefdDEF\nabcaABC')
|
||||||
|
|
||||||
|
it "can't be delimited by numbers", ->
|
||||||
|
keydown(':')
|
||||||
|
submitNormalModeInputText(':substitute 1a1x1gi')
|
||||||
|
expect(atom.notifications.notifications[0].message).toEqual(
|
||||||
|
"Command error: Regular expressions can't be delimited by alphanumeric characters, '\\', '\"' or '|'")
|
||||||
expect(editor.getText()).toEqual('abcaABC\ndefdDEF\nabcaABC')
|
expect(editor.getText()).toEqual('abcaABC\ndefdDEF\nabcaABC')
|
||||||
|
|
||||||
describe "capturing groups", ->
|
describe "capturing groups", ->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue