Don't attempt to move undefined items when splitting panes

This commit is contained in:
Linus Eriksson
2017-08-24 13:40:24 +02:00
parent 236d9011c8
commit 27f17318d7
2 changed files with 27 additions and 1 deletions

View File

@@ -1152,6 +1152,32 @@ describe('Pane', () => {
})
})
describe('when the pane is empty', () => {
describe('when `moveActiveItem: true` is passed in the params', () => {
it('gracefully ignores the moveActiveItem parameter', () => {
pane1.destroyItem(item1)
expect(pane1.getActiveItem()).toBe(undefined)
const pane2 = pane1.split('horizontal', 'before', {moveActiveItem: true})
expect(container.root.children).toEqual([pane2, pane1])
expect(pane2.getActiveItem()).toBe(undefined)
})
})
describe('when `copyActiveItem: true` is passed in the params', () => {
it('gracefully ignores the copyActiveItem parameter', () => {
pane1.destroyItem(item1)
expect(pane1.getActiveItem()).toBe(undefined)
const pane2 = pane1.split('horizontal', 'before', {copyActiveItem: true})
expect(container.root.children).toEqual([pane2, pane1])
expect(pane2.getActiveItem()).toBe(undefined)
})
})
})
it('activates the new pane', () => {
expect(pane1.isActive()).toBe(true)
const pane2 = pane1.splitRight()

View File

@@ -888,7 +888,7 @@ class Pane
when 'before' then @parent.insertChildBefore(this, newPane)
when 'after' then @parent.insertChildAfter(this, newPane)
@moveItemToPane(@activeItem, newPane) if params?.moveActiveItem
@moveItemToPane(@activeItem, newPane) if params?.moveActiveItem and @activeItem
newPane.activate()
newPane