'use babel';

/* @flow*/

import { Observable } from 'rxjs';
import { UPDATE_EDITOR, errorAction } from '../actions';

export default function updateEditor(action$: Observable) {
  return action$.ofType(UPDATE_EDITOR)
    .map(action => console.log(action))
    .catch(err => Observable.of(errorAction(err)));
}

@@ -18,16 +18,55 @@
 @flow*/%0A
+import type %7B TextEditor %7D from 'atom';
 %0Aimport 
@@ -128,16 +128,28 @@
 orAction
+, testAction
  %7D from 
@@ -163,16 +163,592 @@
 ions';%0A%0A
+function handleGutter(textEditor: TextEditor) %7B%0A  if (!textEditor) %7B%0A    return null;%0A  %7D%0A%0A  let gutter = textEditor.gutterWithName('tester');%0A  if (gutter) %7B%0A    try %7B%0A      gutter.destroy();%0A      gutter = null;%0A    %7D catch (error) %7B%0A      console.error('Tester: ', error);%0A    %7D%0A  %7D%0A%0A  if (this.gutterEnabled) %7B%0A    const position = atom.config.get('tester.gutterPosition');%0A    if (textEditor && !textEditor.gutter) %7B%0A      gutter = textEditor.addGutter(%7B%0A        name: 'tester',%0A        priority: position === 'Left' ? -100 : 100,%0A      %7D);%0A    %7D%0A  %7D%0A  return gutter;%0A%7D%0A%0A
 export d
@@ -851,17 +851,27 @@
 map(
+(
 action
+)
  =%3E
+ %7B%0A     
  con
@@ -886,16 +886,317 @@
 (action)
+;%0A      const isTextEditor = atom.workspace.isTextEditor(action.payload.editor);%0A      if (isTextEditor) %7B%0A        handleGutter(action.payload.editor);%0A      %7D%0A      if (atom.config.get('tester.testOnOpen')) %7B%0A        return Observable.of(testAction());%0A      %7D%0A%0A      return Observable.empty();%0A    %7D
 )%0A    .c

handle gutter if editor changed