 
           runs ->
             editorView = atom.workspaceView.getActiveView()
+            editorElement = editorView.element
             {editor} = editorView
             {buffer} = editor
 
         describe 'when within a <tag></tag> pair', ->
           it "moves the cursor to the starting tag", ->
             editor.setCursorBufferPosition([5, 10])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [4, 9]
 
         describe 'when on a starting <tag>', ->
           it 'moves the cursor to the end </tag>', ->
             editor.setCursorBufferPosition([1, 2])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [15, 2]
 
             editor.setCursorBufferPosition([1, 3])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [15, 4]
 
             editor.setCursorBufferPosition([1, 4])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [15, 5]
 
             editor.setCursorBufferPosition([1, 5])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [15, 6]
 
             editor.setCursorBufferPosition([1, 6])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [15, 7]
 
             editor.setCursorBufferPosition([1, 7])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [15, 8]
 
             editor.setCursorBufferPosition([1, 8])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [15, 8]
 
             editor.setCursorBufferPosition([1, 9])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [15, 8]
 
             editor.setCursorBufferPosition([1, 10])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [15, 8]
 
             editor.setCursorBufferPosition([1, 16])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [15, 8]
 
         describe 'when on an ending </tag>', ->
           it 'moves the cursor to the start <tag>', ->
             editor.setCursorBufferPosition([15, 2])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [1, 2]
 
             editor.setCursorBufferPosition([15, 3])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [1, 3]
 
             editor.setCursorBufferPosition([15, 4])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [1, 3]
 
             editor.setCursorBufferPosition([15, 5])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [1, 4]
 
             editor.setCursorBufferPosition([15, 6])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [1, 5]
 
             editor.setCursorBufferPosition([15, 7])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [1, 6]
 
             editor.setCursorBufferPosition([15, 8])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [1, 7]
 
             editor.setCursorBufferPosition([15, 9])
-            editorView.trigger "bracket-matcher:go-to-matching-bracket"
+            atom.commands.dispatch(editorElement, "bracket-matcher:go-to-matching-bracket")
             expect(editor.getCursorBufferPosition()).toEqual [1, 7]
 
   describe "when bracket-matcher:go-to-enclosing-bracket is triggered", ->
     describe "when within a `{}` pair", ->
       it "moves the cursor to before the enclosing brace", ->
         editor.setCursorBufferPosition([11, 2])
-        editorView.trigger "bracket-matcher:go-to-enclosing-bracket"
+        atom.commands.dispatch(editorElement, "bracket-matcher:go-to-enclosing-bracket")
         expect(editor.getCursorBufferPosition()).toEqual [0, 28]
 
     describe "when within a `()` pair", ->
       it "moves the cursor to before the enclosing brace", ->
         editor.setCursorBufferPosition([2, 14])
-        editorView.trigger "bracket-matcher:go-to-enclosing-bracket"
+        atom.commands.dispatch(editorElement, "bracket-matcher:go-to-enclosing-bracket")
         expect(editor.getCursorBufferPosition()).toEqual [2, 7]
 
   describe "when bracket-match:select-inside-brackets is triggered", ->
     describe "when the cursor on the left side of a bracket", ->
       it "selects the text inside the brackets", ->
         editor.setCursorBufferPosition([0,28])
-        editorView.trigger "bracket-matcher:select-inside-brackets"
+        atom.commands.dispatch(editorElement, "bracket-matcher:select-inside-brackets")
         expect(editor.getSelectedBufferRange()).toEqual [[0, 29], [12, 0]]
 
     describe "when the cursor on the right side of a bracket", ->
       it "selects the text inside the brackets", ->
         editor.setCursorBufferPosition([1,30])
-        editorView.trigger "bracket-matcher:select-inside-brackets"
+        atom.commands.dispatch(editorElement, "bracket-matcher:select-inside-brackets")
         expect(editor.getSelectedBufferRange()).toEqual [[1, 30], [9, 2]]
 
     describe "when the cursor is inside the brackets", ->
       it "selects the text for the closest outer brackets", ->
         editor.setCursorBufferPosition([6,6])
-        editorView.trigger "bracket-matcher:select-inside-brackets"
+        atom.commands.dispatch(editorElement, "bracket-matcher:select-inside-brackets")
         expect(editor.getSelectedBufferRange()).toEqual [[4, 29], [7, 4]]
 
     describe 'HTML/XML text', ->

    describe "when the cursor is on the right side of an ending pair, the starting pair on another line", ->
      it "removes both pairs", ->
        editor.setCursorBufferPosition([7,5])
        editorView.trigger "bracket-matcher:remove-matching-brackets"
        expect(editor.lineForBufferRow(4)).toEqual('    while(items.length > 0) ')
        expect(editor.lineForBufferRow(7)).toEqual('    ')
        expect(editor.getCursorBufferPosition()).toEqual([7,4])

      it "does not change the text", ->
        editor.insertText("\"woah(")
        editor.selectAll()
        atom.commands.dispatch(editorElement, "bracket-matcher:remove-brackets-from-selection")
        expect(editor.buffer.getText()).toBe "\"woah("

    describe "when selecting a matching pair of brackets", ->
