Command interpreter can take an address by itself

This commit is contained in:
Corey Johnson
2012-03-21 17:36:43 -07:00
parent a2156e39c0
commit 38debc8107
2 changed files with 7 additions and 2 deletions

View File

@@ -10,6 +10,11 @@ describe "CommandInterpreter", ->
editor = new Editor({buffer})
interpreter = new CommandInterpreter()
describe "addresses", ->
it "selects the given lines", ->
interpreter.eval(editor, '4,7')
expect(editor.selection.getBufferRange()).toEqual [[3, 0], [6, 0]]
describe "substitution", ->
it "does nothing if there are no matches", ->
editor.selection.setBufferRange([[6, 0], [6, 44]])

View File

@@ -4,10 +4,10 @@
}
start
= address:address? _ command:substitution {
= address:address? _ command:substitution? {
var operations = [];
if (address) operations.push(address);
operations.push(command);
if (command) operations.push(command);
return operations;
}