       return @createReplView(uri: m[1])
 
     @disposables.add atom.commands.add 'atom-text-editor',
-      'ide-haskell-repl:toggle': ({target}) =>
-        @open target.getModel()
+      'ide-haskell-repl:toggle': ({currentTarget}) =>
+        @open currentTarget.getModel()
 
-    commandFunction = (func) => ({target}) =>
-      view = @editorMap.get(target.getModel())
+    commandFunction = (func) => ({currentTarget}) =>
+      view = @editorMap.get(currentTarget.getModel())
       if view?
         view[func]()
 

      'ide-haskell-repl:ghci-interrupt': commandFunction 'interrupt'

    @disposables.add atom.commands.add 'atom-text-editor:not(.ide-haskell-repl)',
      'ide-haskell-repl:copy-selection-to-repl-input':  ({target}) =>
        ed = target.getModel()
        cmd = ed.getLastSelection().getText()
        @open(ed)
        .then (model) ->
          model.copyText(cmd)
      'ide-haskell-repl:run-selection-in-repl':  ({target}) =>
        ed = target.getModel()
        cmd = ed.getLastSelection().getText()
        @open(ed, false)
        .then (model) ->
          model.runCommand(cmd)
      'ide-haskell-repl:reload-repeat':  ({target}) =>
        @open(target.getModel(), false)
        .then (model) ->
          model.ghciReloadRepeat()
      'ide-haskell-repl:toggle-auto-reload-repeat':  ({target}) =>
        ed = target.getModel()
        if @autoRepeatMap.has(ed)
          old = @autoRepeatMap.get(ed) ? atom.config.get('ide-haskell-repl.autoReloadRepeat')
          @autoRepeatMap.set(ed, not old)

        disp.dispose()
      disp.add model.onDidDestroy ->
        disp.dispose()
      return model

  deactivate: ->
    @disposables.dispose()
