     @autoIndent = true
     @buildCursorAndSelection()
     @handleEvents()
-    @editorStatesByBufferId = {}
+    @editorStates = []
     @setEditorState(editorState)
 
   bindKeys: ->

    scrollLeft: @scroller.scrollLeft()

  saveEditorStateForCurrentBuffer: ->
    @editorStatesByBufferId[@buffer.id] = @getEditorState()

  handleBufferChange: (e) ->
    @compositeCursor.handleBufferChange(e)

    @buffer.on "change.editor#{@id}", (e) => @handleBufferChange(e)
    @renderer.on 'change', (e) => @handleRendererChange(e)

  getEditorStateForBuffer: (buffer) ->
    _.find @editorStates, (editorState) =>
      editorState.buffer.id == buffer.id

  setEditorStateForBuffer: (buffer, editorState) ->
    editorState.buffer = buffer
    existingEditorState = @getEditorStateForBuffer(buffer)
    if existingEditorState
      _.extend(existingEditorState, editorState)
    else
      @editorStates.push(editorState)

  loadEditorStateForBuffer: (buffer) ->
    editorState = @getEditorStateForBuffer(buffer)
    if not editorState
      editorState = {}
      @setEditorStateForBuffer(buffer, editorState)
    @setCursorScreenPosition(editorState.cursorScreenPosition ? [0, 0])
    @scroller.scrollTop(editorState.scrollTop ? 0)
    @scroller.scrollLeft(editorState.scrollLeft ? 0)

  setEditorState: (editorState={}) ->
    buffer = editorState.buffer ?= new Buffer
    @setEditorStateForBuffer(buffer, editorState)
    @setBuffer(buffer)

  getEditorState: ->
