diff --git a/spec/atom/command-interpreter-spec.coffee b/spec/atom/command-interpreter-spec.coffee index 55e428540..2fea4aab1 100644 --- a/spec/atom/command-interpreter-spec.coffee +++ b/spec/atom/command-interpreter-spec.coffee @@ -104,24 +104,24 @@ describe "CommandInterpreter", -> expect(buffer.lineForRow(5)).toBe '!!!!!!current!=!items.shift();' expect(buffer.lineForRow(6)).toBe ' current < pivot ? left.push(current) : right.push(current);' - describe ".repeatLastRelativeAddress()", -> + describe ".repeatRelativeAddress()", -> it "repeats the last search command", -> editor.setCursorScreenPosition([4, 0]) interpreter.eval(editor, '/current') expect(editor.getSelection().getBufferRange()).toEqual [[5,6], [5,13]] - interpreter.repeatLastRelativeAddress(editor) + interpreter.repeatRelativeAddress(editor) expect(editor.getSelection().getBufferRange()).toEqual [[6,6], [6,13]] interpreter.eval(editor, 's/r/R/g') - interpreter.repeatLastRelativeAddress(editor) + interpreter.repeatRelativeAddress(editor) expect(editor.getSelection().getBufferRange()).toEqual [[6,34], [6,41]] interpreter.eval(editor, '0') interpreter.eval(editor, '/sort/ s/r/R/') # this contains a substitution... won't be repeated - interpreter.repeatLastRelativeAddress(editor) + interpreter.repeatRelativeAddress(editor) expect(editor.getSelection().getBufferRange()).toEqual [[3,31], [3,38]] diff --git a/spec/atom/command-panel-spec.coffee b/spec/atom/command-panel-spec.coffee index c4a127681..034975803 100644 --- a/spec/atom/command-panel-spec.coffee +++ b/spec/atom/command-panel-spec.coffee @@ -33,6 +33,12 @@ describe "CommandPanel", -> expect(commandPanel.editor.buffer.getText()).toBe '' expect(commandPanel.editor.getCursorScreenPosition()).toEqual [0, 0] + describe "when command-panel:repeat-relative-address is triggered on the root view", -> + it "calls .repeatRelativeAddress on the command interpreter with the active editor", -> + spyOn(commandPanel.commandInterpreter, 'repeatRelativeAddress') + rootView.trigger 'command-panel:repeat-relative-address' + expect(commandPanel.commandInterpreter.repeatRelativeAddress).toHaveBeenCalledWith(rootView.activeEditor()) + describe "when esc is pressed in the command panel", -> it "closes the command panel", -> rootView.trigger 'command-panel:toggle' diff --git a/src/atom/command-interpreter.coffee b/src/atom/command-interpreter.coffee index 765a14317..86ac82d48 100644 --- a/src/atom/command-interpreter.coffee +++ b/src/atom/command-interpreter.coffee @@ -11,6 +11,6 @@ class CommandInterpreter @lastRelativeAddress = command if command.isRelativeAddress() command.execute(editor) - repeatLastRelativeAddress: (editor) -> + repeatRelativeAddress: (editor) -> @lastRelativeAddress.execute(editor) diff --git a/src/atom/command-panel.coffee b/src/atom/command-panel.coffee index 611ecabd3..c45c58342 100644 --- a/src/atom/command-panel.coffee +++ b/src/atom/command-panel.coffee @@ -17,8 +17,12 @@ class CommandPanel extends View escape: 'command-panel:toggle' enter: 'command-panel:execute' + window.keymap.bindKeys '.editor', + 'meta-g': 'command-panel:repeat-relative-address' + @rootView.on 'command-panel:toggle', => @toggle() @rootView.on 'command-panel:execute', => @execute() + @rootView.on 'command-panel:repeat-relative-address', => @repeatRelativeAddress() @editor.addClass 'single-line' @commandInterpreter = new CommandInterpreter() @@ -35,4 +39,7 @@ class CommandPanel extends View execute: -> @commandInterpreter.eval(@rootView.activeEditor(), @editor.getText()) - @toggle() \ No newline at end of file + @toggle() + + repeatRelativeAddress: -> + @commandInterpreter.repeatRelativeAddress(@rootView.activeEditor())