         atom.config.set(keyPath, not atom.config.get(keyPath))
 
     previewFile = @previewFile.bind(this)
-    atom.commands.add '.tree-view .file .name[data-name$=\\.markdown]', 'markdown-preview:preview-file', previewFile
-    atom.commands.add '.tree-view .file .name[data-name$=\\.md]', 'markdown-preview:preview-file', previewFile
-    atom.commands.add '.tree-view .file .name[data-name$=\\.mdown]', 'markdown-preview:preview-file', previewFile
-    atom.commands.add '.tree-view .file .name[data-name$=\\.mkd]', 'markdown-preview:preview-file', previewFile
-    atom.commands.add '.tree-view .file .name[data-name$=\\.mkdown]', 'markdown-preview:preview-file', previewFile
-    atom.commands.add '.tree-view .file .name[data-name$=\\.ron]', 'markdown-preview:preview-file', previewFile
-    atom.commands.add '.tree-view .file .name[data-name$=\\.txt]', 'markdown-preview:preview-file', previewFile
+    for extension in ['markdown', 'md', 'mdown', 'mkd', 'mkdown', 'ron', 'txt']
+      # FIXME: This doesn't work. Individual elements in the Tree View do not get focus
+      # so this selector never matches.
+      @disposables.add atom.commands.add ".tree-view .file .name[data-name$=\\.#{extension}]",
+        'markdown-preview:preview-file', previewFile
 
-    atom.workspace.addOpener (uriToOpen) =>
+    @disposables.add atom.workspace.addOpener (uriToOpen) =>
       [protocol, path] = uriToOpen.split('://')
       return unless protocol is 'markdown-preview'
 

      else
        atom.clipboard.write(html)

  saveAsHtml: ->
    activePane = atom.workspace.getActivePaneItem()
    if isMarkdownPreviewView(activePane)
      activePane.saveAs()

url = require 'url'
fs = require 'fs-plus'
{CompositeDisposable} = require 'atom'

MarkdownPreviewView = null
renderer = null
