         selectNext = new SelectNext(editor)
         @selectNextObjects.set(editor, selectNext)
       selectNext
+
+    showPanel = (panelToShow, panelToHide, action) ->
+      panelToHide.hide()
+      panelToShow.show()
+      if action then action()
+
+    togglePanel = (panelToToggle, panelToHide, action) ->
+      panelToHide.hide()
+
+      if panelToToggle.isVisible()
+        panelToToggle.hide()
+      else
+        panelToToggle.show()
+        if action then action()
 
     atom.commands.add '.editor:not(.mini)',
       'find-and-replace:select-next': (event) ->


    @subscriptions.add atom.commands.add 'atom-workspace', 'find-and-replace:toggle', =>
      @createViews()
      @projectFindPanel.hide()

      if @findPanel.isVisible()
        @findPanel.hide()
      else
        @findPanel.show()
        @findView.focusFindEditor()

    @subscriptions.add atom.commands.add 'atom-workspace', 'find-and-replace:show', =>
      @createViews()
      @projectFindPanel.hide()
      @findPanel.show()
      @findView.focusFindEditor()

    @subscriptions.add atom.commands.add 'atom-workspace', 'find-and-replace:show-replace', =>
      @createViews()
      @projectFindPanel?.hide()
      @findPanel.show()
      @findView.focusReplaceEditor()

    # Handling cancel in the workspace + code editors
    handleEditorCancel = ({target}) =>


    @subscriptions.add atom.commands.add 'atom-workspace', 'project-find:show', =>
      @createViews()
      showPanel(@projectFindPanel, @findPanel, @projectFindView.focusFindElement)

    @subscriptions.add atom.commands.add 'atom-workspace', 'project-find:toggle', =>
      @createViews()
      togglePanel @projectFindPanel, @findPanel, @projectFindView.focusFindElement

    @subscriptions.add atom.commands.add 'atom-workspace', 'project-find:show-in-current-directory', ({target}) =>
      @createViews()
