From 38debc8107a428f74f4797df8d13f85ebcbe4d1a Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 21 Mar 2012 17:36:43 -0700 Subject: [PATCH] Command interpreter can take an address by itself --- spec/atom/command-interpreter-spec.coffee | 5 +++++ src/atom/commands.pegjs | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/atom/command-interpreter-spec.coffee b/spec/atom/command-interpreter-spec.coffee index 9c30546e8..0b39d430b 100644 --- a/spec/atom/command-interpreter-spec.coffee +++ b/spec/atom/command-interpreter-spec.coffee @@ -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]]) diff --git a/src/atom/commands.pegjs b/src/atom/commands.pegjs index 2c85a647f..74f52b110 100644 --- a/src/atom/commands.pegjs +++ b/src/atom/commands.pegjs @@ -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; }