       @setBuffer(new Buffer)
 
   serialize: ->
-    @saveCurrentEditSession()
+    @saveActiveEditSession()
     { viewClass: "Editor", editSessions: @serializeEditSessions(), @activeEditSessionIndex, @isFocused }
 
   serializeEditSessions: ->

    @scrollTop(@activeEditSession.scrollTop ? 0)
    @scrollView.scrollLeft(@activeEditSession.scrollLeft ? 0)

  saveCurrentEditSession: ->
    @activeEditSession.setCursorScreenPosition(@getCursorScreenPosition())
    @activeEditSession.setScrollTop(@scrollTop())
    @activeEditSession.setScrollLeft(@scrollView.scrollLeft())

  setActiveEditSessionIndex: (index) ->
    throw new Error("Edit session not found") unless @editSessions[index]

    @saveActiveEditSession() if @activeEditSession

    @activeEditSession = @editSessions[index]
    @activeEditSessionIndex = index
