     @showResultPane()
     @model.search(@findEditor.getText(), paths)
 
+  replaceAll: ->
+    @clearMessages()
+    pattern = @findEditor.getText()
+    replacementText = @replaceEditor.getText()
+    @model.replace(pattern, replacementText, @model.getPaths())
+
   showResultPane: ->
     options = null
     options = {split: 'right'} if config.get('find-and-replace.openProjectFindResultsInRightPane')
     rootView.openSingletonSync(ResultsPaneView.URI, options)
 
   clearMessages: ->
+    # @replacmentInfoBlock.hide()
     @errorMessages.hide().empty()
     @infoMessages.hide().empty()
 

    if editor
      pattern = editor.activeEditSession.getSelectedText()
      @findEditor.setText(pattern)

  replaceAll: ->
    @clearMessages()

    pattern = @findEditor.getText()
    replacementText = @replaceEditor.getText()
    promise = @model.replace(pattern, replacementText, @model.getPaths())

    if @model.getPathCount()
      @model.once 'finished-replacing', ({pathsReplaced, replacements}) =>
        @addInfoMessage("Replaced #{_.pluralize(replacements, 'result')} in #{_.pluralize(pathsReplaced, 'file')}")
    else
      shell.beep()
      @addInfoMessage("Nothing replaced")

    promise


    rootView.command 'find-and-replace:use-selection-as-find-pattern', @setSelectionAsFindPattern

    @handleEventsForReplace()

  handleEventsForReplace: ->
    @replacementsMade = 0
    @model.on 'replace', (promise) =>
      # if @model.getPathCount()
      @replacementsMade = 0
      @replacmentInfoBlock.show()
      @replacementProgress.removeAttr('value')

    @model.on 'path-replaced', (result) =>
      @replacementsMade++
      @replacementProgress[0].value = @replacementsMade / @model.getPathCount()
      @replacmentInfo.text("Replaced #{@replacementsMade} of #{_.pluralize(@model.getPathCount(), 'file')}")

    @model.on 'finished-replacing', ({pathsReplaced, replacements}) =>
      @replacmentInfoBlock.hide()
      if pathsReplaced
        @addInfoMessage("Replaced #{_.pluralize(replacements, 'result')} in #{_.pluralize(pathsReplaced, 'file')}")
      else
        shell.beep()
        @addInfoMessage("Nothing replaced")

  attach: ->
    if @hasParent()
      el = @lastFocusedElement or @findEditor
