       @setLink(selection, "", "")
 
   updateSearch: ->
-    return unless @posts
     query = @searchEditor.getText().trim().toLowerCase()
-    results = @posts.filter (post) ->
+    results = posts.filter (post) ->
       query and post.title.toLowerCase().contains(query)
     results = results.map (post) ->
       "<li data-url='#{post.url}'>#{post.title}</li>"

    @on "core:cancel", => @detach()

  handleEvents: ->
    @searchEditor.hiddenInput.on "keyup", => @updateSearch()
    @searchResult.on "click", "li", (e) => @useSearchResult(e)

  onConfirm: ->

path = require "path"
fs = require "fs-plus"

posts = null # to cache it

module.exports =
class AddLinkView extends View
  editor: null
  links: null
  referenceId: false
  previouslyFocusedElement: null
