diff --git a/spec/app/pane-spec.coffee b/spec/app/pane-spec.coffee index bb5c0b430..6004ced05 100644 --- a/spec/app/pane-spec.coffee +++ b/spec/app/pane-spec.coffee @@ -91,6 +91,12 @@ describe "Pane", -> pane.removeItem(editSession2) expect(editSession2.destroyed).toBeTruthy() + describe "core:close", -> + it "removes the current item", -> + initialItemCount = pane.getItems().length + pane.trigger 'core:close' + expect(pane.getItems().length).toBe initialItemCount - 1 + 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.currentItem).toBe view1 diff --git a/src/app/pane.coffee b/src/app/pane.coffee index 3f6a8c2ba..4b9a20357 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -20,6 +20,7 @@ class Pane extends View @viewsByClassName = {} @showItem(@items[0]) + @command 'core:close', @removeCurrentItem @command 'pane:show-next-item', @showNextItem @command 'pane:show-previous-item', @showPreviousItem @command 'pane:split-left', => @splitLeft() @@ -65,6 +66,9 @@ class Pane extends View @items.splice(@getCurrentItemIndex() + 1, 0, item) item + removeCurrentItem: => + @removeItem(@currentItem) + removeItem: (item) -> @showNextItem() if item is @currentItem and @items.length > 1 _.remove(@items, item)