         @subAtom = new SubAtom
         self = this
         atom.workspace.observeTextEditors (editor) ->
-            self.registerEvents editor, editor.getGrammar()
+            self.registerEvents editor
 
+        # When you go back to only have 1 pane the events are lost, so need
+        # to re-register.
         atom.workspace.onDidDestroyPane (pane) ->
             panes = atom.workspace.getPanes()
             if panes.length == 1
                 for paneItem in panes[0].items
                     if paneItem instanceof TextEditor
-                        self.registerEvents paneItem, paneItem.getGrammar()
+                        self.registerEvents paneItem
 
+        # Having to re-register events as when a new pane is created the
+        # old panes lose the events.
         atom.workspace.onDidAddPane (observedPane) ->
             panes = atom.workspace.getPanes()
             for pane in panes

                    continue
                for paneItem in pane.items
                    if paneItem instanceof TextEditor
                        self.registerEvents paneItem, paneItem.getGrammar()

        @selectView = new GotoSelectView

    ###*
     * Goto the class the cursor is on
     * @param {TextEditor} editor
    ###
    gotoFromEditor: (editor) ->
        if editor.getGrammar().scopeName.match /text.html.php$/

                    @gotoFromWord(editor, $(selector).text())
                    event.handled = true

    ###*
     * Gets the correct selector when a class or namespace is clicked.
     * @param  {jQuery.Event}  event  A jQuery event.
     * @return {object|null}          A selector to be used with jQuery.
    ###
    getSelector: (event) ->
        selector = event.currentTarget

