Merge pull request #14460 from atom/jr-activate-next-or-previous-pane-in-dock

Fix ability to activate next/previous pane in a dock
This commit is contained in:
Jason Rudolph
2017-05-22 10:03:26 -04:00
committed by GitHub
3 changed files with 130 additions and 0 deletions

View File

@@ -62,6 +62,70 @@ describe('Dock', () => {
})
})
describe('activating the next pane', () => {
describe('when the dock has more than one pane', () => {
it('activates the next pane', () => {
const dock = atom.workspace.getLeftDock()
const pane1 = dock.getPanes()[0]
const pane2 = pane1.splitRight()
const pane3 = pane2.splitRight()
pane2.activate()
expect(pane1.isActive()).toBe(false)
expect(pane2.isActive()).toBe(true)
expect(pane3.isActive()).toBe(false)
dock.activateNextPane()
expect(pane1.isActive()).toBe(false)
expect(pane2.isActive()).toBe(false)
expect(pane3.isActive()).toBe(true)
})
})
describe('when the dock has only one pane', () => {
it('leaves the current pane active', () => {
const dock = atom.workspace.getLeftDock()
expect(dock.getPanes().length).toBe(1)
const pane = dock.getPanes()[0]
expect(pane.isActive()).toBe(true)
dock.activateNextPane()
expect(pane.isActive()).toBe(true)
})
})
})
describe('activating the previous pane', () => {
describe('when the dock has more than one pane', () => {
it('activates the previous pane', () => {
const dock = atom.workspace.getLeftDock()
const pane1 = dock.getPanes()[0]
const pane2 = pane1.splitRight()
const pane3 = pane2.splitRight()
pane2.activate()
expect(pane1.isActive()).toBe(false)
expect(pane2.isActive()).toBe(true)
expect(pane3.isActive()).toBe(false)
dock.activatePreviousPane()
expect(pane1.isActive()).toBe(true)
expect(pane2.isActive()).toBe(false)
expect(pane3.isActive()).toBe(false)
})
})
describe('when the dock has only one pane', () => {
it('leaves the current pane active', () => {
const dock = atom.workspace.getLeftDock()
expect(dock.getPanes().length).toBe(1)
const pane = dock.getPanes()[0]
expect(pane.isActive()).toBe(true)
dock.activatePreviousPane()
expect(pane.isActive()).toBe(true)
})
})
})
describe('when the dock resize handle is double-clicked', () => {
describe('when the dock is open', () => {
it('resizes a vertically-oriented dock to the current item\'s preferred width', async () => {

View File

@@ -2528,6 +2528,62 @@ i = /test/; #FIXME\
})
})
describe('::activateNextPane', () => {
describe('when the active workspace pane is inside a dock', () => {
it('activates the next pane in the dock', () => {
const dock = atom.workspace.getLeftDock()
const dockPane1 = dock.getPanes()[0]
const dockPane2 = dockPane1.splitRight()
dockPane2.focus()
expect(atom.workspace.getActivePane()).toBe(dockPane2)
atom.workspace.activateNextPane()
expect(atom.workspace.getActivePane()).toBe(dockPane1)
})
})
describe('when the active workspace pane is inside the workspace center', () => {
it('activates the next pane in the workspace center', () => {
const center = atom.workspace.getCenter()
const centerPane1 = center.getPanes()[0]
const centerPane2 = centerPane1.splitRight()
centerPane2.focus()
expect(atom.workspace.getActivePane()).toBe(centerPane2)
atom.workspace.activateNextPane()
expect(atom.workspace.getActivePane()).toBe(centerPane1)
})
})
})
describe('::activatePreviousPane', () => {
describe('when the active workspace pane is inside a dock', () => {
it('activates the previous pane in the dock', () => {
const dock = atom.workspace.getLeftDock()
const dockPane1 = dock.getPanes()[0]
const dockPane2 = dockPane1.splitRight()
dockPane1.focus()
expect(atom.workspace.getActivePane()).toBe(dockPane1)
atom.workspace.activatePreviousPane()
expect(atom.workspace.getActivePane()).toBe(dockPane2)
})
})
describe('when the active workspace pane is inside the workspace center', () => {
it('activates the previous pane in the workspace center', () => {
const center = atom.workspace.getCenter()
const centerPane1 = center.getPanes()[0]
const centerPane2 = centerPane1.splitRight()
centerPane1.focus()
expect(atom.workspace.getActivePane()).toBe(centerPane1)
atom.workspace.activatePreviousPane()
expect(atom.workspace.getActivePane()).toBe(centerPane2)
})
})
})
describe('when the core.allowPendingPaneItems option is falsey', () => {
it('does not open item with `pending: true` option as pending', () => {
let pane = null

View File

@@ -626,6 +626,16 @@ module.exports = class Dock {
return this.paneContainer.getActivePane()
}
// Extended: Make the next pane active.
activateNextPane () {
return this.paneContainer.activateNextPane()
}
// Extended: Make the previous pane active.
activatePreviousPane () {
return this.paneContainer.activatePreviousPane()
}
paneForURI (uri) {
return this.paneContainer.paneForURI(uri)
}