     if @markers?.length
       @replaceHistory.store()
       @findHistory.store()
-      @findModel.replace(@markers, @replaceEditor.getText())
+      @model.replace(@markers, @replaceEditor.getText())
     else
       atom.beep()
 


  updateOptionsLabel: ->
    label = []
    label.push('Regex') if @findModel.getFindOptions().useRegex
    if @findModel.getFindOptions().caseSensitive
      label.push('Case Sensitive')
    else
      label.push('Case Insensitive')
    label.push('Within Current Selection') if @findModel.getFindOptions().inCurrentSelection
    label.push('Whole Word') if @findModel.getFindOptions().wholeWord
    @optionsLabel.text(label.join(', '))

  updateOptionButtons: ->
    @setOptionButtonState(@regexOptionButton, @findModel.getFindOptions().useRegex)
    @setOptionButtonState(@caseOptionButton, @findModel.getFindOptions().caseSensitive)
    @setOptionButtonState(@selectionOptionButton, @findModel.getFindOptions().inCurrentSelection)
    @setOptionButtonState(@wholeWordOptionButton, @findModel.getFindOptions().wholeWord)

  setOptionButtonState: (optionButton, selected) ->
    if selected

    @updateResultCounter()
    @updateReplaceEnablement()

    if @model.getFindOptions().findPattern
      results = @markers.length
      resultsStr = if results then _.pluralize(results, 'result') else 'No results'
      @setInfoMessage("#{resultsStr} found for '#{@model.getFindOptions().findPattern}'")
      if @findEditor.hasFocus() and results > 0 and atom.config.get('find-and-replace.scrollToResultOnLiveSearch')
        @findAndSelectResult(@selectFirstMarkerStartingFromCursor, focusEditorAfter: false)
    else
      @clearMessage()

    if @model.getFindOptions().findPattern isnt @findEditor.getText()
      @findEditor.setText(@model.getFindOptions().findPattern)

  findError: (error) =>
    @setErrorMessage(error.message)

  updateModel: (options) ->
    @model.setFindOptions(options)

  updateResultCounter: =>
    if @model.currentResultMarker and (index = @markers.indexOf(@model.currentResultMarker)) > -1
      text = "#{ index + 1} of #{@markers.length}"
    else
      if not @markers? or @markers.length is 0
