     element.textContent = grammar.name
     element
 
-  populate: ->
+  confirmed: (grammar) ->
+    @cancel()
+    if grammar is @autoDetect
+      atom.syntax.clearGrammarOverrideForPath(@editor.getPath())
+    else
+      atom.syntax.setGrammarOverrideForPath(@editor.getPath(), grammar.scopeName)
+    @editor.reloadGrammar()
+
+  attach: ->
+    @storeFocusedElement()
+    atom.workspaceView.append(this)
+    @focusEditor()
+
+  getGrammars: ->
     grammars = atom.syntax.getGrammars().filter (grammar) ->
       grammar isnt atom.syntax.nullGrammar
 

      else
        grammarA.name.localeCompare(grammarB.name)
    grammars.unshift(@autoDetect)
    @setItems(grammars)

  confirmed: (grammar) ->
    @cancel()
    if grammar is @autoDetect
      atom.syntax.clearGrammarOverrideForPath(@editor.getPath())
    else
      atom.syntax.setGrammarOverrideForPath(@editor.getPath(), grammar.scopeName)
    @editor.reloadGrammar()

  attach: ->
    super

    atom.workspaceView.append(this)
    @focusEditor()

      @cancel()
      false

    @setItems(@getGrammars())
    @attach()

  getFilterKey: ->
