diff --git a/spec/app/pane-spec.coffee b/spec/app/pane-spec.coffee index 96973f95e..d657e9b5c 100644 --- a/spec/app/pane-spec.coffee +++ b/spec/app/pane-spec.coffee @@ -306,6 +306,27 @@ describe "Pane", -> pane.trigger 'core:save' expect(atom.showSaveDialog).not.toHaveBeenCalled() + describe "core:save-as", -> + beforeEach -> + spyOn(atom, 'showSaveDialog') + + describe "when the current item has a saveAs method", -> + it "opens the save dialog and calls saveAs on the item with the selected path", -> + spyOn(editSession2, 'saveAs') + pane.showItem(editSession2) + + pane.trigger 'core:save-as' + + expect(atom.showSaveDialog).toHaveBeenCalled() + atom.showSaveDialog.argsForCall[0][0]('/selected/path') + expect(editSession2.saveAs).toHaveBeenCalledWith('/selected/path') + + describe "when the current item does not have a saveAs method", -> + it "does nothing", -> + expect(pane.activeItem.saveAs).toBeUndefined() + pane.trigger 'core:save-as' + expect(atom.showSaveDialog).not.toHaveBeenCalled() + describe "pane:show-next-item and pane:show-previous-item", -> it "advances forward/backward through the pane's items, looping around at either end", -> expect(pane.activeItem).toBe view1 diff --git a/src/app/editor.coffee b/src/app/editor.coffee index f9b65b835..0f900eb47 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -152,7 +152,6 @@ class Editor extends View 'core:select-down': @selectDown 'core:select-to-top': @selectToTop 'core:select-to-bottom': @selectToBottom - 'editor:save-as': @saveAs 'editor:newline-below': @insertNewlineBelow 'editor:newline-above': @insertNewlineAbove 'editor:toggle-soft-tabs': @toggleSoftTabs @@ -610,12 +609,6 @@ class Editor extends View @removeClass 'soft-wrap' $(window).off 'resize', @_setSoftWrapColumn - saveAs: (session=@activeEditSession, onSuccess) -> - atom.showSaveDialog (path) => - if path - session.saveAs(path) - onSuccess?() - autosave: -> @save() if @getPath()? diff --git a/src/app/keymaps/atom.cson b/src/app/keymaps/atom.cson index eb6b1628e..29e83880a 100644 --- a/src/app/keymaps/atom.cson +++ b/src/app/keymaps/atom.cson @@ -1,5 +1,6 @@ 'body': 'meta-s': 'core:save' + 'meta-S': 'core:save-as' 'enter': 'core:confirm' 'escape': 'core:cancel' 'meta-w': 'core:close' diff --git a/src/app/keymaps/editor.cson b/src/app/keymaps/editor.cson index fc8c859d4..066385507 100644 --- a/src/app/keymaps/editor.cson +++ b/src/app/keymaps/editor.cson @@ -2,7 +2,6 @@ 'meta-T': 'editor:undo-close-session' '.editor': - 'meta-S': 'editor:save-as' 'enter': 'editor:newline' 'meta-enter': 'editor:newline-below' 'meta-shift-enter': 'editor:newline-above' diff --git a/src/app/pane.coffee b/src/app/pane.coffee index 3295daa20..0696b24da 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -22,6 +22,7 @@ class Pane extends View @command 'core:close', @destroyActiveItem @command 'core:save', @saveActiveItem + @command 'core:save-as', @saveActiveItemAs @command 'pane:show-next-item', @showNextItem @command 'pane:show-previous-item', @showPreviousItem @command 'pane:split-left', => @splitLeft() @@ -119,12 +120,20 @@ class Pane extends View saveActiveItem: => @saveItem(@activeItem) + saveActiveItemAs: => + @saveItemAs(@activeItem) + saveItem: (item, nextAction) -> if item.getPath?() item.save() nextAction?() - else if item.saveAs? - atom.showSaveDialog (path) -> + else + @saveItemAs(item, nextAction) + + saveItemAs: (item, nextAction) -> + return unless item.saveAs? + atom.showSaveDialog (path) => + if path item.saveAs(path) nextAction?()