 
 module.exports =
 class EditSession
-  @idCounter: 1
-
   @deserialize: (state, project) ->
     if fs.exists(state.buffer)
       session = project.buildEditSessionForPath(state.buffer)

  softWrap: false

  constructor: ({@project, @buffer, tabLength, @autoIndent, softTabs, @softWrap }) ->
    @id = @constructor.idCounter++
    @softTabs = @buffer.usesSoftTabs() ? softTabs ? true
    @languageMode = new LanguageMode(this, @buffer.getExtension())
    @displayBuffer = new DisplayBuffer(@buffer, { @languageMode, tabLength })

    @addCursorAtScreenPosition([0, 0])

    @buffer.retain()
    @subscribe @buffer, "path-changed", => @trigger "path-changed"
    @subscribe @buffer, "contents-conflicted", => @trigger "contents-conflicted"
    @subscribe @buffer, "anchors-updated", => @mergeCursors()

    @preserveCursorPositionOnBufferReload()

    @subscribe @displayBuffer, "changed", (e) =>
      @refreshAnchorScreenPositions() unless e.bufferDelta
      @trigger 'screen-lines-changed', e

  destroy: ->
    throw new Error("Edit session already destroyed") if @destroyed
    @destroyed = true
    @unsubscribe()
    @buffer.release()
    @displayBuffer.destroy()
    @project.removeEditSession(this)
    anchor.destroy() for anchor in @getAnchors()
