diff --git a/spec/dock-spec.js b/spec/dock-spec.js index 49aa95f25..f9b8a5326 100644 --- a/spec/dock-spec.js +++ b/spec/dock-spec.js @@ -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 () => { diff --git a/spec/workspace-spec.js b/spec/workspace-spec.js index 6dc9d025d..9eaa17bcd 100644 --- a/spec/workspace-spec.js +++ b/spec/workspace-spec.js @@ -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 diff --git a/src/dock.js b/src/dock.js index 0e6d60e4e..d531e8627 100644 --- a/src/dock.js +++ b/src/dock.js @@ -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) }