Improve handling of pending items when moving items b/t panes

* Make pending items permanent when moved to new panes
* Ensure existing pending items are not destroyed when a new
  item is added to the same pane

Signed-off-by: Michelle Tilley <binarymuse@github.com>
This commit is contained in:
Katrina Uychaco
2016-03-04 15:26:43 -08:00
committed by Michelle Tilley
parent a4b57a31b7
commit 59b6c7f6fa
2 changed files with 18 additions and 1 deletions

View File

@@ -680,6 +680,23 @@ describe "Pane", ->
expect(pane2.isDestroyed()).toBe true
expect(item4.isDestroyed()).toBe false
describe "when the item being moved is pending", ->
it "is made permanent in the new pane", ->
item6 = new Item("F")
pane1.addItem(item6, pending: true)
expect(pane1.getPendingItem()).toEqual item6
pane1.moveItemToPane(item6, pane2, 0)
expect(pane2.getPendingItem()).not.toEqual item6
describe "when the target pane has a pending item", ->
it "does not destroy the pending item", ->
item6 = new Item("F")
pane1.addItem(item6, pending: true)
expect(pane1.getPendingItem()).toEqual item6
pane2.moveItemToPane(item5, pane1, 0)
expect(pane1.getPendingItem()).toEqual item6
describe "split methods", ->
[pane1, item1, container] = []

View File

@@ -404,7 +404,7 @@ class Pane extends Model
@setPendingItem(item) if pending
@emitter.emit 'did-add-item', {item, index, moved}
@destroyItem(lastPendingItem) if lastPendingItem?
@destroyItem(lastPendingItem) if lastPendingItem? and not moved
@setActiveItem(item) unless @getActiveItem()?
item