Close all editors in pane with meta-P

This commit is contained in:
Kevin Sawicki 2013-01-08 09:06:20 -08:00
parent fffba45b50
commit 7465ae5052
3 changed files with 20 additions and 0 deletions

View File

@ -2077,3 +2077,15 @@ describe "Editor", ->
expect(atom.confirm).toHaveBeenCalled()
expect(editor.getEditSessions().length).toBe 2
expect(editor.getEditSessions()[0].buffer.isModified()).toBeTruthy()
describe ".destroyAllEditSessions()", ->
it "destroys every edit session", ->
rootView.open('sample.txt')
rootView.open('css.css')
rootView.open('coffee.coffee')
rootView.open('hello.rb')
expect(editor.getEditSessions().length).toBe 5
editor.setActiveEditSessionIndex(2)
editor.destroyAllEditSessions()
expect(editor.pane()).toBeUndefined()
expect(editor.getEditSessions().length).toBe 0

View File

@ -177,6 +177,7 @@ class Editor extends View
'editor:log-cursor-scope': @logCursorScope
'editor:checkout-head-revision': @checkoutHead
'editor:close-other-editors': @destroyInactiveEditSessions
'editor:close-all-editors': @destroyAllEditSessions
documentation = {}
for name, method of editorBindings
@ -470,6 +471,12 @@ class Editor extends View
index++ if @activeEditSession is @editSessions[index]
@destroyEditSessionIndex(index, destroyIndex) if @editSessions[index]
destroyIndex(0)
destroyAllEditSessions: ->
destroyIndex = (index) =>
@destroyEditSessionIndex(index, destroyIndex) if @editSessions[index]
destroyIndex(0)
loadNextEditSession: ->
nextIndex = (@getActiveEditSessionIndex() + 1) % @editSessions.length
@setActiveEditSessionIndex(nextIndex)

View File

@ -33,3 +33,4 @@
'meta-u': 'editor:upper-case'
'meta-U': 'editor:lower-case'
'alt-meta-w': 'editor:close-other-editors'
'meta-P': 'editor:close-all-editors'