Add pane:close-other-items

This commit is contained in:
Nathan Sobo 2013-03-01 17:26:16 -07:00 committed by probablycorey
parent 4b8d786d2a
commit f23d9091f2
2 changed files with 11 additions and 0 deletions

View File

@ -278,6 +278,13 @@ describe "Pane", ->
expect(editSession2.destroyed).toBeTruthy()
expect(editSession1.destroyed).toBeTruthy()
describe "pane:close-other-items", ->
it "destroys all items except the current", ->
pane.showItem(editSession1)
pane.trigger 'pane:close-other-items'
expect(editSession2.destroyed).toBeTruthy()
expect(pane.getItems()).toEqual [editSession1]
describe "core:save", ->
describe "when the current item has a path", ->
describe "when the current item has a save method", ->

View File

@ -31,6 +31,7 @@ class Pane extends View
@command 'pane:split-up', => @splitUp()
@command 'pane:split-down', => @splitDown()
@command 'pane:close', => @destroyItems()
@command 'pane:close-other-items', => @destroyInactiveItems()
@on 'focus', => @activeView.focus(); false
@on 'focusin', => @makeActive()
@ -112,6 +113,9 @@ class Pane extends View
destroyItems: ->
@destroyItem(item) for item in @getItems()
destroyInactiveItems: ->
@destroyItem(item) for item in @getItems() when item isnt @activeItem
promptToSaveItem: (item, nextAction) ->
path = item.getPath()
atom.confirm(