mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Merge branch 'master' of github.com:github/atom into edit-session-refactor
This commit is contained in:
@@ -2686,8 +2686,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()
|
||||
|
||||
@@ -223,7 +223,6 @@ class Editor extends View
|
||||
else
|
||||
@gutter.addClass('drop-shadow')
|
||||
|
||||
|
||||
afterAttach: (onDom) ->
|
||||
return if @attached or not onDom
|
||||
@attached = true
|
||||
@@ -346,6 +345,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)
|
||||
@@ -378,6 +385,9 @@ class Editor extends View
|
||||
@activeEditSession.on 'add-cursor', (cursor) =>
|
||||
@compositeCursor.addCursorView(cursor)
|
||||
|
||||
destroyEditSessions: ->
|
||||
session.destroy() for session in @editSessions
|
||||
|
||||
setScrollPositionFromActiveEditSession: ->
|
||||
@scrollTop(@activeEditSession.scrollTop ? 0)
|
||||
@scrollView.scrollLeft(@activeEditSession.scrollLeft ? 0)
|
||||
@@ -750,8 +760,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
|
||||
|
||||
@@ -766,11 +779,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
|
||||
|
||||
Reference in New Issue
Block a user