 
 metrics = throttle metrics, 60*60*1000
 
-resultEditorRegistry = {}
+resultEditorRegistry = new Set
+layers = {}
 
 module.exports =
 class Result

    ed = atom.workspace.getActiveTextEditor()
    for sel in ed.getSelections()
      rs = @forLines ed, sel.getHeadBufferPosition().row, sel.getTailBufferPosition().row
      rs.map (r) -> r.toggleView()

  # Commands

      result.invalidate()

  @forLines: (ed, start, end, type = 'any') ->
    layers[ed.id]?.findMarkers(intersectsBufferRowRange: [start, end])
                  .filter((m) -> (m.result.type == type || type == 'any'))
                  .map((m) -> m.result)

  @removeLines: (ed, start, end, type = 'any') ->
    rs = @forLines(ed, start, end, type)
    return unless rs?
    rs.map (r) -> r.remove()
    rs.length > 0

  @removeAll: (ed = atom.workspace.getActiveTextEditor()) ->
    layers[ed.id]?.getMarkers().map((m) -> m.result.remove())

  @removeCurrent: (e) ->
    if (ed = atom.workspace.getActiveTextEditor())
