mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Close empty active window when Close command is given
This commit is contained in:
@@ -1438,11 +1438,11 @@ describe "Workspace", ->
|
||||
save = -> atom.workspace.saveActivePaneItem()
|
||||
expect(save).toThrow()
|
||||
|
||||
describe "::destroyActivePaneItemOrEmptyPane", ->
|
||||
describe "::closeActivePaneItemOrEmptyPaneOrWindow", ->
|
||||
beforeEach ->
|
||||
waitsForPromise -> atom.workspace.open()
|
||||
|
||||
it "closes the active pane item until all that remains is a single empty pane", ->
|
||||
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", ->
|
||||
atom.config.set('core.destroyEmptyPanes', false)
|
||||
|
||||
pane1 = atom.workspace.getActivePane()
|
||||
@@ -1450,19 +1450,23 @@ describe "Workspace", ->
|
||||
|
||||
expect(atom.workspace.getPanes().length).toBe 2
|
||||
expect(pane2.getItems().length).toBe 1
|
||||
atom.workspace.destroyActivePaneItemOrEmptyPane()
|
||||
atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow()
|
||||
|
||||
expect(atom.workspace.getPanes().length).toBe 2
|
||||
expect(pane2.getItems().length).toBe 0
|
||||
|
||||
atom.workspace.destroyActivePaneItemOrEmptyPane()
|
||||
atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow()
|
||||
|
||||
expect(atom.workspace.getPanes().length).toBe 1
|
||||
expect(pane1.getItems().length).toBe 1
|
||||
|
||||
atom.workspace.destroyActivePaneItemOrEmptyPane()
|
||||
atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow()
|
||||
expect(atom.workspace.getPanes().length).toBe 1
|
||||
expect(pane1.getItems().length).toBe 0
|
||||
|
||||
atom.workspace.destroyActivePaneItemOrEmptyPane()
|
||||
atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow()
|
||||
expect(atom.workspace.getPanes().length).toBe 1
|
||||
|
||||
spyOn(atom, 'close')
|
||||
atom.workspace.closeActivePaneItemOrEmptyPaneOrWindow()
|
||||
expect(atom.close).toHaveBeenCalled()
|
||||
|
||||
@@ -55,7 +55,7 @@ module.exports = ({commandRegistry, commandInstaller, config}) ->
|
||||
'window:log-deprecation-warnings': -> Grim.logDeprecations()
|
||||
'window:toggle-auto-indent': -> config.set("editor.autoIndent", not config.get("editor.autoIndent"))
|
||||
'pane:reopen-closed-item': -> @getModel().reopenItem()
|
||||
'core:close': -> @getModel().destroyActivePaneItemOrEmptyPane()
|
||||
'core:close': -> @getModel().closeActivePaneItemOrEmptyPaneOrWindow()
|
||||
'core:save': -> @getModel().saveActivePaneItem()
|
||||
'core:save-as': -> @getModel().saveActivePaneItemAs()
|
||||
|
||||
|
||||
@@ -675,9 +675,15 @@ class Workspace extends Model
|
||||
destroyActivePane: ->
|
||||
@getActivePane()?.destroy()
|
||||
|
||||
# Destroy the active pane item or the active pane if it is empty.
|
||||
destroyActivePaneItemOrEmptyPane: ->
|
||||
if @getActivePaneItem()? then @destroyActivePaneItem() else @destroyActivePane()
|
||||
# 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.
|
||||
closeActivePaneItemOrEmptyPaneOrWindow: ->
|
||||
if @getActivePaneItem()?
|
||||
@destroyActivePaneItem()
|
||||
else if @getPanes().length > 1
|
||||
@destroyActivePane()
|
||||
else
|
||||
atom.close()
|
||||
|
||||
# Increase the editor font size by 1px.
|
||||
increaseFontSize: ->
|
||||
|
||||
Reference in New Issue
Block a user