   constructor: ({@editorId, @filePath}) ->
     super
 
+    @disposables = new CompositeDisposable
+
+    unless @editorId?
+      if atom.workspace?
+        @subscribeToFilePath(@filePath)
+      else
+        @disposables.add atom.packages.onDidActivateAll =>
+          @subscribeToFilePath(@filePath)
+
   afterAttach: ->
     return if @attached
 
     @attached = true
     if @editorId?
       @resolveEditor(@editorId)
-    else
-      if atom.workspace? and atom.workspaceView?
-        @subscribeToFilePath(@filePath)
-      else
-        @subscribe atom.packages.once 'activated', =>
-          @subscribeToFilePath(@filePath)
 
   beforeRemove: ->
     @attached = false

    null

  handleEvents: ->
    @subscribe atom.grammars.onDidAddGrammar _.debounce((=> @renderMarkdown()), 250)
    @subscribe atom.grammars.onDidUpdateGrammar _.debounce((=> @renderMarkdown()), 250)

    atom.commands.add @element,
      'core:move-up': =>

path = require 'path'

{CompositeDisposable} = require 'atom'
{$, $$$, ScrollView} = require 'atom'
_ = require 'underscore-plus'
fs = require 'fs-plus'
