From f23d9091f2b2f70830e1336c3df719839c74219b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 1 Mar 2013 17:26:16 -0700 Subject: [PATCH] Add pane:close-other-items --- spec/app/pane-spec.coffee | 7 +++++++ src/app/pane.coffee | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/spec/app/pane-spec.coffee b/spec/app/pane-spec.coffee index d4066292e..103aa13ba 100644 --- a/spec/app/pane-spec.coffee +++ b/spec/app/pane-spec.coffee @@ -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", -> diff --git a/src/app/pane.coffee b/src/app/pane.coffee index 1cbe2c312..3978ca696 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -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(