'use babel';

import EditorController from './editor-controller.js';

export default class Controller {
  constructor() {
    this.editorCtrlers = new Set();

    this.editorsSub = atom.workspace.observeTextEditors(editor => {
      const editorCtrler = new EditorController(editor);
      this.editorCtrlers.add(editorCtrler);

      const destroySub = editor.onDidDestroy(() => {
        destroySub.dispose();

        editorCtrler.destroy();
        this.editorCtrlers.delete(editorCtrler);
      });
    });
  }

  destroy() {
    this.editorsSub.dispose();

    for (const editorCtrler of this.editorCtrlers) {
      editorCtrler.destroy();
    }
  }
}

@@ -7,16 +7,61 @@
 abel';%0A%0A
+import %7B CompositeDisposable %7D from 'atom';%0A%0A
 import E
@@ -193,11 +193,11 @@
 new 
-Set
+Map
 ();%0A
@@ -219,16 +219,67 @@
 rsSub = 
+new CompositeDisposable();%0A    this.editorsSub.add(
 atom.wor
@@ -326,48 +326,21 @@
     
-const editorCtrler = new EditorControlle
+this.addEdito
 r(ed
@@ -344,24 +344,31 @@
 (editor);%0A  
+  %7D));%0A
     this.edi
@@ -374,83 +374,57 @@
 itor
-Ctrlers.add(editorCtrler);%0A%0A      const destroySub = editor.onDidDestroy(()
+sSub.add(atom.workspace.onDidDestroyPaneItem(item
  =%3E 
@@ -435,69 +435,124 @@
     
- 
- destroySub.dispose();%0A%0A        editorCtrler.destroy();%0A    
+this.removeEditor(item);%0A    %7D));%0A  %7D%0A%0A  addEditor(editor) %7B%0A    const editorCtrler = new EditorController(editor);%0A
     
@@ -574,15 +574,20 @@
 ers.
-delete(
+set(editor, 
 edit
@@ -603,21 +603,72 @@
 ;%0A  
-    %7D);%0A    %7D
+%7D%0A%0A  removeEditor(editor) %7B%0A    this.editorCtrlers.delete(editor
 );%0A 

Modify editor observation