 
     @subscriptions.add atom.commands.add 'atom-workspace', 'find-and-replace:toggle', =>
       @createViews()
-      @projectFindPanel.hide()
-
-      if @findPanel.isVisible()
-        @findPanel.hide()
-      else
-        @findPanel.show()
-        @findView.focusFindEditor()
+      togglePanel @findPanel, @projectFindPanel, @findView.focusFindEditor
 
     @subscriptions.add atom.commands.add 'atom-workspace', 'find-and-replace:show', =>
       @createViews()
-      @projectFindPanel.hide()
-      @findPanel.show()
-      @findView.focusFindEditor()
+      showPanel @findPanel, @projectFindPanel, @findView.focusFindEditor
 
     @subscriptions.add atom.commands.add 'atom-workspace', 'find-and-replace:show-replace', =>
       @createViews()
-      @projectFindPanel?.hide()
-      @findPanel.show()
-      @findView.focusReplaceEditor()
+      showPanel @findPanel, @projectFindPanel, @findView.focusReplaceEditor
 
     # Handling cancel in the workspace + code editors
     handleEditorCancel = ({target}) =>

        selectNext = new SelectNext(editor)
        @selectNextObjects.set(editor, selectNext)
      selectNext

    atom.commands.add '.editor:not(.mini)',
      'find-and-replace:select-next': (event) ->


    @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()
