       [oneRange, twoRange, threeRange] = []
 
       beforeEach ->
-        editorView.trigger 'find-and-replace:show'
+        atom.commands.dispatch editorView, 'find-and-replace:show'
         editor.setText("zero\none\ntwo\nthree\n")
         findView.findEditor.setText('one')
         atom.commands.dispatch(findView.findEditor[0], 'core:confirm')

            atom.project.open('sample.coffee').then (o) -> newEditor = o

          runs ->
            newEditorView = editorView.getPaneView().splitRight(newEditor).activeView
            expect(findView.resultCounter.text()).toEqual('7 found')
            expect(newEditorView.getModel().getSelectedBufferRange()).toEqual [[0, 0], [0, 0]]

            atom.commands.dispatch(findView.findEditor[0], 'find-and-replace:find-next')
            expect(findView.resultCounter.text()).toEqual('1 of 7')
            expect(newEditorView.getModel().getSelectedBufferRange()).toEqual [[1, 9], [1, 14]]

        it "highlights the found text in the new edit session (and removes the highlights from the other)", ->
          [newEditor, newEditorView] = []

          waitsForPromise ->
            atom.project.open('sample.coffee').then (o) -> newEditor = o

          runs ->
            newEditorView = editorView.getPaneView().splitRight(newEditor).activeView

          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", ->
          [newEditor, newEditorView] = []

          waitsForPromise ->
            atom.project.open('sample.coffee').then (o) -> newEditor = o

          runs ->
            newEditorView = editorView.getPaneView().splitRight(newEditor).activeView
            expect(newEditorView.find('.find-result')).toHaveLength 7

            newEditorView.focus()
            newEditorView.trigger('core:close')
            editorView.focus()

          runs ->
            expect(editorView.find('.find-result')).toHaveLength 6

    describe "when the buffer contents change", ->
      it "re-runs the search", ->
        findResultsView = editorView.find('.search-results')
        editor.setSelectedBufferRange([[1, 26], [1, 27]])
        editor.insertText("")


  describe "replacing", ->
    beforeEach ->
      editor.setCursorBufferPosition([2,0])
      atom.commands.dispatch editorView, 'find-and-replace:show-replace'

      waitsForPromise ->
        activationPromise
