mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 23:48:05 +03:00
meta-w closes edit sessions until there are none left, then it closes the editor
This commit is contained in:
parent
e167afd794
commit
481ec16485
@ -2685,8 +2685,16 @@ describe "Editor", ->
|
||||
editor.splitRight()
|
||||
|
||||
describe "when 'close' is triggered", ->
|
||||
it "calls remove on the editor if mini is false", ->
|
||||
it "closes active edit session and loads next edit session", ->
|
||||
editor.setBuffer(new Buffer())
|
||||
spyOn(editor, "remove")
|
||||
editor.trigger "close"
|
||||
expect(editor.remove).not.toHaveBeenCalled()
|
||||
expect(editor.buffer).toBe buffer
|
||||
|
||||
it "calls remove on the editor if there is one edit session and mini is false", ->
|
||||
expect(editor.mini).toBeFalsy()
|
||||
expect(editor.editSessions.length).toBe 1
|
||||
spyOn(editor, 'remove')
|
||||
editor.trigger 'close'
|
||||
expect(editor.remove).toHaveBeenCalled()
|
||||
|
@ -220,7 +220,6 @@ class Editor extends View
|
||||
else
|
||||
@gutter.addClass('drop-shadow')
|
||||
|
||||
|
||||
afterAttach: (onDom) ->
|
||||
return if @attached or not onDom
|
||||
@attached = true
|
||||
@ -343,6 +342,14 @@ class Editor extends View
|
||||
return index if editSession.buffer == buffer
|
||||
null
|
||||
|
||||
removeActiveEditSession: ->
|
||||
if @editSessions.length == 1
|
||||
@remove()
|
||||
else
|
||||
editSession = @activeEditSession
|
||||
@loadPreviousEditSession()
|
||||
_.remove(@editSessions, editSession)
|
||||
|
||||
loadNextEditSession: ->
|
||||
nextIndex = (@activeEditSessionIndex + 1) % @editSessions.length
|
||||
@setActiveEditSessionIndex(nextIndex)
|
||||
@ -367,6 +374,9 @@ class Editor extends View
|
||||
@renderLines()
|
||||
@setCursorScreenPosition(@activeEditSession.cursorScreenPosition ? [0, 0])
|
||||
|
||||
destroyEditSessions: ->
|
||||
session.destroy() for session in @editSessions
|
||||
|
||||
setScrollPositionFromActiveEditSession: ->
|
||||
@scrollTop(@activeEditSession.scrollTop ? 0)
|
||||
@scrollView.scrollLeft(@activeEditSession.scrollLeft ? 0)
|
||||
@ -739,8 +749,11 @@ class Editor extends View
|
||||
@parent('.pane').view()
|
||||
|
||||
close: ->
|
||||
@remove() unless @mini
|
||||
return if @mini
|
||||
@removeActiveEditSession()
|
||||
|
||||
unsubscribeFromBuffer: ->
|
||||
@buffer.off ".editor#{@id}"
|
||||
remove: (selector, keepData) ->
|
||||
return super if keepData
|
||||
|
||||
@ -755,11 +768,7 @@ class Editor extends View
|
||||
if @pane() then @pane().remove() else super
|
||||
rootView?.focus()
|
||||
|
||||
unsubscribeFromBuffer: ->
|
||||
@buffer.off ".editor#{@id}"
|
||||
|
||||
destroyEditSessions: ->
|
||||
session.destroy() for session in @editSessions
|
||||
|
||||
stateForScreenRow: (row) ->
|
||||
@renderer.lineForRow(row).state
|
||||
|
Loading…
Reference in New Issue
Block a user