     false
 
   showRailRoadDiagram: (regex, flavour) ->
-    rr = @view.find '.regex-railroad-diagram'
+    rr = @spView.find '.regex-railroad-diagram'
+
     if not rr.length
       # create current diff
       @hide()
 
       # append to "panes"
-      @view.getActivePaneView().parents('.panes').eq(0).after(@)
+      v = atom.views.getView(atom.workspace.getActivePane())
+      $(v).parents('.panes').eq(0).after(@)
 
     @children().remove()
     Regex2RailRoadDiagram(regex, @.get(0), flavour: flavour)

    @currentEditor = null

    #@view.command "regex-railroad-diagram:toggle", => @toggle()
    @view = atom.views.getView(atom.workspace).__spacePenView

    atom.workspace.observeTextEditors (editor) =>
      editor.onDidChangeCursorPosition (event) =>

            text = m[1]

      if not @isVisible or @currentRegex != text
        @spView.find('div.error-message').remove()
        try
          @showRailRoadDiagram(text, flavour)
        catch error
