mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
Close inactive editor sessions on alt-meta-w
This commit is contained in:
@@ -2042,3 +2042,19 @@ describe "Editor", ->
|
||||
event.shiftKey = true
|
||||
editor.underlayer.trigger event
|
||||
expect(editor.getSelection().getScreenRange()).toEqual [[0,0], [12,2]]
|
||||
|
||||
describe ".destroyInactiveEditSessions()", ->
|
||||
it "destroys all non-active, non-modified edit sessions", ->
|
||||
editor.setText("I'm dirty")
|
||||
dirtySession = editor.activeEditSession
|
||||
rootView.open('sample.txt')
|
||||
cssSession = rootView.open('css.css')
|
||||
rootView.open('coffee.coffee')
|
||||
rootView.open('hello.rb')
|
||||
expect(editor.getEditSessions().length).toBe 5
|
||||
editor.setActiveEditSessionIndex(2)
|
||||
editor.destroyInactiveEditSessions()
|
||||
expect(editor.getActiveEditSessionIndex()).toBe 1
|
||||
expect(editor.getEditSessions().length).toBe 2
|
||||
expect(editor.getEditSessions()[0]).toBe dirtySession
|
||||
expect(editor.getEditSessions()[1]).toBe cssSession
|
||||
|
||||
@@ -176,6 +176,7 @@ class Editor extends View
|
||||
'editor:toggle-line-comments': @toggleLineCommentsInSelection
|
||||
'editor:log-cursor-scope': @logCursorScope
|
||||
'editor:checkout-head-revision': @checkoutHead
|
||||
'editor:close-other-editors': @destroyInactiveEditSessions
|
||||
|
||||
documentation = {}
|
||||
for name, method of editorBindings
|
||||
@@ -457,6 +458,14 @@ class Editor extends View
|
||||
editSession.destroy()
|
||||
@trigger 'editor:edit-session-removed', [editSession, index]
|
||||
|
||||
destroyInactiveEditSessions: ->
|
||||
index = 0
|
||||
while session = @editSessions[index]
|
||||
if @activeEditSession is session or session.buffer.isModified()
|
||||
index++
|
||||
else
|
||||
@destroyEditSessionIndex(index)
|
||||
|
||||
loadNextEditSession: ->
|
||||
nextIndex = (@getActiveEditSessionIndex() + 1) % @editSessions.length
|
||||
@setActiveEditSessionIndex(nextIndex)
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
'meta-enter': 'editor:newline-below'
|
||||
'tab': 'editor:indent'
|
||||
'meta-d': 'editor:delete-line'
|
||||
'alt-meta-w': 'editor:toggle-soft-wrap'
|
||||
'ctrl-[': 'editor:fold-current-row'
|
||||
'ctrl-]': 'editor:unfold-current-row'
|
||||
'ctrl-{': 'editor:fold-all'
|
||||
@@ -33,3 +32,4 @@
|
||||
'meta-alt-p': 'editor:log-cursor-scope'
|
||||
'meta-u': 'editor:upper-case'
|
||||
'meta-U': 'editor:lower-case'
|
||||
'alt-meta-w': 'editor:close-other-editors'
|
||||
|
||||
Reference in New Issue
Block a user