Don't throw error when saving empty pane

Closes #1440
This commit is contained in:
Kevin Sawicki
2014-01-17 15:24:55 -08:00
parent c305384334
commit e0cf20cda9
2 changed files with 4 additions and 2 deletions

View File

@@ -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", ->

View File

@@ -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