mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Make Pane close the current item when handling 'core:close' event
This commit is contained in:
committed by
probablycorey
parent
11a702a2a6
commit
bd8ec81b1e
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user