 Cursor = require 'cursor'
 Selection = require 'selection'
 EventEmitter = require 'event-emitter'
+Subscriber = require 'subscriber'
 Range = require 'range'
 AnchorRange = require 'anchor-range'
 _ = require 'underscore'

  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 })


  preserveCursorPositionOnBufferReload: ->
    cursorPosition = null
    @subscribe @buffer, "will-reload", =>
      cursorPosition = @getCursorBufferPosition()
    @subscribe @buffer, "reloaded", =>
      @setCursorBufferPosition(cursorPosition) if cursorPosition
      cursorPosition = null

_.extend(EditSession.prototype, EventEmitter)
_.extend(EditSession.prototype, Subscriber)
