     pattern = @findModel.getEditSession().getSelectedText()
     @findModel.update {pattern}
 
+  clearMessages: ->
+    @errorMessages.hide().empty()
+    @infoMessages.hide().empty()
+
+  addInfoMessage: (message) ->
+    @infoMessages.append($$$ -> @li message)
+    @infoMessages.show()
+
+  addErrorMessage: (message) ->
+    @errorMessages.append($$$ -> @li message)
+    @errorMessages.show()
+
   toggleRegexOption: =>
     @findModel.update {pattern: @findEditor.getText(), useRegex: !@findModel.useRegex}
     @selectFirstMarkerAfterCursor()

      return index if markerStartPosition.isGreaterThan(start)
    0

  selectFirstMarkerBeforeCursor: ->
    markerIndex = @firstMarkerIndexBeforeCursor()
    @selectMarkerAtIndex(markerIndex)


    @findNext()

  findNext: (focusEditorAfter = true) =>
    @findAndSelectResult(@selectFirstMarkerAfterCursor, focusEditorAfter)

  findPrevious: (focusEditorAfter = true) =>
    @findAndSelectResult(@selectFirstMarkerBeforeCursor, focusEditorAfter)

  findAndSelectResult: (selectFunction, focusEditorAfter = true) =>
    @clearMessages()
    pattern = @findEditor.getText()
    @findModel.update { pattern }

    if @markers.length == 0
      @addInfoMessage("No results found for '#{pattern}'")
      shell.beep()
    else
      selectFunction()
      rootView.focus() if focusEditorAfter

  replaceNext: =>
    @clearMessages()
    pattern = @findEditor.getText()
    @findModel.update { pattern }

    if @markers.length == 0
      @addInfoMessage("No results found for '#{pattern}'")
      shell.beep()
    else
      unless currentMarker = @currentResultMarker
