From e0cf20cda99889ae192b015191211b5add506833 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 17 Jan 2014 15:24:55 -0800 Subject: [PATCH] Don't throw error when saving empty pane Closes #1440 --- spec/pane-spec.coffee | 2 ++ src/pane.coffee | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/pane-spec.coffee b/spec/pane-spec.coffee index d68b4370b..92229befc 100644 --- a/spec/pane-spec.coffee +++ b/spec/pane-spec.coffee @@ -184,6 +184,8 @@ describe "Pane", -> pane.destroyItem(item) for item in pane.getItems() expect(pane.isDestroyed()).toBe false expect(pane.activeItem).toBeUndefined() + expect(-> pane.saveActiveItem()).not.toThrow() + expect(-> pane.saveActiveItemAs()).not.toThrow() describe "when the 'core.destroyEmptyPanes' config option is true", -> it "destroys the pane", -> diff --git a/src/pane.coffee b/src/pane.coffee index f38760989..6afdf5b6f 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -239,7 +239,7 @@ class Pane extends Model # * item: The item to save. # * nextAction: An optional function which will be called after the item is saved. saveItem: (item, nextAction) -> - if item.getUri?() + if item?.getUri?() item.save?() nextAction?() else @@ -250,7 +250,7 @@ class Pane extends Model # * item: The item to save. # * nextAction: An optional function which will be called after the item is saved. saveItemAs: (item, nextAction) -> - return unless item.saveAs? + return unless item?.saveAs? itemPath = item.getPath?() itemPath = dirname(itemPath) if itemPath