 {$} = require 'atom'
+{Subscriber} = require 'emissary'
 
 SelectNext = require './select-next'
 FindModel = require './find-model'

      else
        @projectFindView.attach()

    atom.workspaceView.command 'project-find:show-in-current-directory', (e) =>
      @createProjectFindView()
      @findView?.detach()
      @projectFindView.attach()
      @projectFindView.findInCurrentlySelectedDirectory($(e.target))

    atom.workspaceView.command 'find-and-replace:use-selection-as-find-pattern', =>
      return if @projectFindView?.isOnDom() or @findView?.isOnDom()

      @createFindView()
      @projectFindView?.detach()
      @findView.showFind()

    atom.workspaceView.command 'find-and-replace:toggle', =>
      @createFindView()
      @projectFindView?.detach()


      else
        @findView.showFind()

    @subscriber.subscribeToCommand atom.workspaceView, 'find-and-replace:show', =>
      @createFindView()
      @projectFindView?.detach()
      @findView.showFind()

    @subscriber.subscribeToCommand atom.workspaceView, 'find-and-replace:show-replace', =>
      @createFindView()
      @projectFindView?.detach()
      @findView.showReplace()

    # in code editors
    @subscriber.subscribeToCommand atom.workspaceView, 'core:cancel core:close', ({target}) =>
      if target isnt atom.workspaceView.getActivePaneView()?[0]
        editor = $(target).parents('.editor:not(.mini)')
        return unless editor.length
