           expect(newEditorView.getEditor().getSelectedBufferRange()).toEqual [[1, 9], [1, 14]]
 
         it "highlights the found text in the new edit session (and removes the highlights from the other)", ->
-          findResultsView = editorView.find('.search-results')
-
-          expect(findResultsView.children()).toHaveLength 6
-          editorView.getPane().splitRight(atom.project.openSync('sample.coffee'))
-          expect(findResultsView.children()).toHaveLength 7
+          newEditorView = editorView.getPane().splitRight(atom.project.openSync('sample.coffee'))
+
+          waits 1
+          runs ->
+            # old editor has no more results
+            expect(editorView.find('.find-result')).toHaveLength 0
+
+            # new one has 7 results
+            expect(newEditorView.find('.find-result')).toHaveLength 7
 
         it "will still highlight results after the split pane has been destroyed", ->
-          findResultsView = editorView.find('.search-results')
-          expect(findResultsView.children()).toHaveLength 6
-
           newEditorView = editorView.getPane().splitRight(atom.project.openSync('sample.coffee'))
-          expect(findResultsView.children()).toHaveLength 7
+          expect(newEditorView.find('.find-result')).toHaveLength 7
 
           newEditorView.focus()
           newEditorView.trigger('core:close')
           editorView.focus()
-          expect(findResultsView.children()).toHaveLength 6
+
+          waits 1
+          runs ->
+            expect(editorView.find('.find-result')).toHaveLength 6
 
     describe "when the buffer contents change", ->
       it "re-runs the search", ->

        editor.insertText("")

        window.advanceClock(1000)
        expect(findResultsView.children()).toHaveLength 5
        expect(findView.resultCounter.text()).toEqual('5 found')

        editor.insertText("s")
        window.advanceClock(1000)
        expect(findResultsView.children()).toHaveLength 6
        expect(findView.resultCounter.text()).toEqual('6 found')

      it "does not beep if no matches were found", ->

        expect(editor.getSelectedBufferRange()).toEqual [[2, 0], [2, 5]]

    describe "highlighting search results", ->
      resultPosition = (result) ->
        {top: result.children()[0].style.top, left: result.children()[0].style.left}

      it "only highlights matches", ->
        expect(editorView.find('.find-result')).toHaveLength 6

        findView.findEditor.setText 'notinthefilebro'
        findView.findEditor.trigger 'core:confirm'

        waits 1
        runs ->
          expect(editorView.find('.find-result')).toHaveLength 0

      it "adds a class to the current match indicating it is the current match", ->
        position = (result) ->
          {top: result.children()[0].style.top, left: result.children()[0].style.left}

        firstResult = editorView.find('.current-result')
        firstPosition = resultPosition(firstResult)
        expect(editorView.find('.find-result')).toHaveLength 6
        expect(firstResult).toHaveLength 1

        findView.findEditor.trigger 'core:confirm'
        findView.findEditor.trigger 'core:confirm'
        waits 1
        runs ->
          nextResult = editorView.find('.current-result')
          nextPosition = resultPosition(nextResult)
          expect(nextResult).toHaveLength 1
          expect(nextPosition).not.toEqual firstPosition

          findView.findEditor.trigger 'find-and-replace:find-previous'
          findView.findEditor.trigger 'find-and-replace:find-previous'

        waits 1
        runs ->
          originalResult = editorView.find('.current-result')
          originalPosition = resultPosition(originalResult)
          expect(originalResult).toHaveLength 1
          expect(originalPosition).toEqual firstPosition

      it "adds a class to the result when the current selection equals the result's range", ->
        originalResult = editorView.find('.current-result')
        originalPosition = resultPosition(originalResult)
        expect(originalResult).toHaveLength 1

        editor.setSelectedBufferRange([[5, 16], [5, 20]])

        waits 1
        runs ->
          expect(editorView.find('.current-result')).toHaveLength 0
          editor.setSelectedBufferRange([[5, 16], [5, 21]])

        waits 1
        runs ->
          newResult = editorView.find('.current-result')
          newPosition = resultPosition(newResult)
          expect(newResult).toHaveLength 1
          expect(newPosition).not.toBe originalPosition

    describe "when user types in the find editor", ->
      advance = ->
