     disposableBufferEvent = editor.buffer.onDidChange (e) =>
                         @autoCloseTag e, editor
 
-    @disposables.push(disposableBufferEvent);
+    @disposables.add editor.onDidDestroy => disposableBufferEvent.dispose()
+
+    @disposables.add(disposableBufferEvent);
 
   deactivate: ->
-    for disposable in @disposables
-      disposable.dispose()
+    @disposables.dispose()
   activate: ->
 
-    @disposables = [];
+    @disposables = new CompositeDisposable();
 
     jsxTagStartPattern = '(?x)((^|=|return)\\s*<([^!/?](?!.+?(</.+?>))))'
     jsxComplexAttributePattern = '(?x)\\{ [^}"\']* $|\\( [^)"\']* $'

            editor.setCursorBufferPosition([firstChangedLine, range[0][1]])

  autoCloseTag: (eventObj, editor) ->
    return if not @isReactEnabledForEditor editor

    if eventObj?.newText is '>' and !eventObj.oldText
      tokenizedLine = editor.displayBuffer?.tokenizedBuffer?.tokenizedLineForRow(eventObj.newRange.end.row)

{CompositeDisposable, Disposable} = require 'atom'

contentCheckRegex = null
defaultDetectReactFilePattern = '/((require\\([\'"]react(?:-native)?[\'"]\\)))|(import\\s+\\w+\\s+from\\s+[\'"]react(?:-native)?[\'"])/'
autoCompleteTagStartRegex = /(<)([a-zA-Z0-9\.:$_]+)/g
