diff --git a/keymaps/atom-runner.cson b/keymaps/atom-runner.cson index 7b8e4a2..9a4d15b 100644 --- a/keymaps/atom-runner.cson +++ b/keymaps/atom-runner.cson @@ -10,10 +10,12 @@ '.platform-darwin atom-text-editor': 'ctrl-r': 'run:file' 'ctrl-shift-r': 'run:selection' + 'ctrl-q': 'run:prev' '.platform-win32 atom-text-editor, .platform-linux atom-text-editor': 'alt-r': 'run:file' 'alt-shift-r': 'run:selection' + 'alt-q': 'run:prev' '.platform-darwin .atom-runner': 'cmd-c': 'run:copy' diff --git a/lib/atom-runner.coffee b/lib/atom-runner.coffee index c4fffd7..95a1d09 100644 --- a/lib/atom-runner.coffee +++ b/lib/atom-runner.coffee @@ -36,6 +36,7 @@ class AtomRunner extensionMap: null scopeMap: null + prev: null debug: (args...) -> console.debug('[atom-runner]', args...) @@ -70,11 +71,13 @@ class AtomRunner atom.commands.add 'atom-workspace', 'run:selection', => @run(true) atom.commands.add 'atom-workspace', 'run:stop', => @stop() atom.commands.add 'atom-workspace', 'run:close', => @stopAndClose() + atom.commands.add 'atom-workspace', 'run:prev', => @run(false, true) atom.commands.add '.atom-runner', 'run:copy', => atom.clipboard.write(window.getSelection().toString()) - run: (selection) -> + run: (selection, rerun=false) -> editor = atom.workspace.getActiveTextEditor() + editor = @prev if rerun return unless editor? path = editor.getPath() @@ -105,6 +108,8 @@ class AtomRunner view.setTitle(editor.getTitle()) pane.activateItem(view) + @prev = editor + @execute(cmd, editor, view, selection) stop: (view) ->