       @requestUpdate()
 
   onCursorAdded: (cursor) ->
-    @subscribe cursor.onDidChangePosition @onCursorMoved
+    @disposables.add cursor.onDidChangePosition @onCursorMoved
 
   onCursorMoved: ->
     @cursorMoved = true

        # clipboard.writeText is a sync ipc call on Linux and that
        # will slow down selections.
        ipc.send('write-text-to-selection-clipboard', selectedText)
    @subscribe editor.onDidChangeSelectionRange ->
      clearTimeout(timeoutId)
      timeoutId = setTimeout(writeSelectedTextToSelectionClipboard)

  observeConfig: ->
    @subscribe atom.config.onDidChange 'editor.fontSize', @sampleFontStyling
    @subscribe atom.config.onDidChange 'editor.fontFamily', @sampleFontStyling
    @subscribe atom.config.onDidChange 'editor.lineHeight', @sampleFontStyling

  onGrammarChanged: ->
    {editor} = @props

    @scopedConfigSubscriptions?.dispose()
    @scopedConfigSubscriptions = subscriptions = new CompositeDisposable

    scopeDescriptor = editor.getRootScopeDescriptor()

    subscriptions.add atom.config.observe 'editor.scrollSensitivity', scope: scopeDescriptor, @setScrollSensitivity

  focused: ->
    if @isMounted()

LinesComponent = require './lines-component'
ScrollbarComponent = require './scrollbar-component'
ScrollbarCornerComponent = require './scrollbar-corner-component'

module.exports =
TextEditorComponent = React.createClass
  displayName: 'TextEditorComponent'

  pendingScrollTop: null
  pendingScrollLeft: null
