From 66609a14146401e4986ca5061cbcc5f9e49fcaec Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 10 May 2017 13:21:50 -0600 Subject: [PATCH 1/2] Act on active center items only when saving and closing Signed-off-by: Max Brunsfeld --- src/workspace.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/workspace.js b/src/workspace.js index cbf38602f..9235afb53 100644 --- a/src/workspace.js +++ b/src/workspace.js @@ -1307,7 +1307,7 @@ module.exports = class Workspace extends Model { // {::saveActivePaneItemAs} # will be called instead. This method does nothing // if the active item does not implement a `.save` method. saveActivePaneItem () { - this.getActivePane().saveActiveItem() + this.getCenter().getActivePane().saveActiveItem() } // Prompt the user for a path and save the active pane item to it. @@ -1316,7 +1316,7 @@ module.exports = class Workspace extends Model { // `.saveAs` on the item with the selected path. This method does nothing if // the active item does not implement a `.saveAs` method. saveActivePaneItemAs () { - this.getActivePane().saveActiveItemAs() + this.getCenter().getActivePane().saveActiveItemAs() } // Destroy (close) the active pane item. @@ -1419,13 +1419,13 @@ module.exports = class Workspace extends Model { } } - // Close the active pane item, or the active pane if it is empty, - // or the current window if there is only the empty root pane. + // Close the active center pane item, or the active center pane if it is + // empty, or the current window if there is only the empty root pane. closeActivePaneItemOrEmptyPaneOrWindow () { - if (this.getActivePaneItem() != null) { - this.destroyActivePaneItem() + if (this.getCenter().getActivePaneItem() != null) { + this.getCenter().getActivePane().destroyActiveItem() } else if (this.getCenter().getPanes().length > 1) { - this.destroyActivePane() + this.getCenter().destroyActivePane() } else if (this.config.get('core.closeEmptyWindows')) { atom.close() } From 048a5484622d4042cf9584ef7cce4015ad1a5935 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 10 May 2017 14:18:15 -0600 Subject: [PATCH 2/2] Fix specs --- spec/workspace-spec.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/spec/workspace-spec.js b/spec/workspace-spec.js index 8d6477a26..6dc9d025d 100644 --- a/spec/workspace-spec.js +++ b/spec/workspace-spec.js @@ -2486,7 +2486,7 @@ i = /test/; #FIXME\ waitsForPromise(() => atom.workspace.open()) }) - it('closes the active pane item, or the active pane if it is empty, or the current window if there is only the empty root pane', async () => { + it('closes the active center pane item, or the active center pane if it is empty, or the current window if there is only the empty root pane in the center', async () => { atom.config.set('core.destroyEmptyPanes', false) const pane1 = atom.workspace.getActivePane() @@ -2509,6 +2509,7 @@ i = /test/; #FIXME\ expect(pane1.getItems().length).toBe(0) expect(atom.workspace.getCenter().getPanes().length).toBe(1) + // The dock items should not be closed await atom.workspace.open({ getTitle: () => 'Permanent Dock Item', element: document.createElement('div'), @@ -2523,13 +2524,6 @@ i = /test/; #FIXME\ expect(atom.workspace.getLeftDock().getPaneItems().length).toBe(2) atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow() - expect(atom.workspace.getLeftDock().getPaneItems().length).toBe(1) - atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow() - expect(atom.workspace.getLeftDock().getPaneItems().length).toBe(1) - expect(atom.close).not.toHaveBeenCalled() - - atom.workspace.getCenter().activate() - atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow() expect(atom.close).toHaveBeenCalled() }) })