 
       onClose = =>
         if @activeRepl is repl
-          @activeRepl = null
+          @destoryRepl()
         delete @repls[uri]
 
       repl = new Repl(uri, @projectRoot, onClose)
-      @activeRepl = repl
+      @activateRepl repl
       @repls[uri] = repl
       window = repl.createPostWindow()
       repl.startSCLang()

          # offset syntax error by position of selected text in file
          row = range.getRows()[0] + error.error.syntaxErrors.line - 1
          col = error.error.syntaxErrors.charPos
          @openFile(path, null, row, col)

      # dbug = JSON.stringify(error, undefined, 2)
      # console.log dbug
      # @bus.push "<div class='pre debug'>#{dbug}</div>"

    if @activeRepl
      # if stuck in compile error

        .then () =>
          @activeRepl.eval(expression, false, path)
            .then(null, onError)

  openToSyntaxError: (path, line, char) ->
    @openFile(path, null, line, char)

  openHelpFile: ->
    unless @editorIsSC()
