   process: null
   subscriptions: null
   numInstances: 0
+  editorMap: null
 
   config:
     checkOnSave:

      el

    @subscriptions.add atom.commands.add 'atom-text-editor',
      'haskell-ghc-mod:type': ->
        @getModel().haskellGhcModController?.getType()
      'haskell-ghc-mod:info': ->
        @getModel().haskellGhcModController?.getInfo()
      'haskell-ghc-mod:insert-type': ->
        @getModel().haskellGhcModController?.insertType()
      'haskell-ghc-mod:check': ->
        @getModel().haskellGhcModController?.doCheck()

    @subscriptions.add atom.workspace.observeTextEditors (editor) =>
      return unless editor.getGrammar().scopeName=="source.haskell"
      @numInstances += 1
      @process = new GhcModiProcess unless @process
      editor.haskellGhcModController = new EditorController(@process,editor)
      editor.onDidDestroy =>
        editor.haskellGhcModController?.destroy()
        @numInstances -= 1
        if @numInstances==0
          @process?.destroy()


  deactivate: ->
    for editor in atom.workspace.getEditors()
      @editorMap.get(editor)?.desrtoy()
      @editorMap.delete(editor)
    @subscriptions.dispose()
    @process?.destroy()
