anchor.diff:      inherit TextEditorExtension()
   
       let pathChanged = new Event<_,_>()
  -    let ext = ref Unchecked.defaultof<_>
       let mutable currentPath = [||]
       member x.Document = base.Document
       member x.GetEntityMarkup(node: DeclarationItem) =
  
positive.code: 
      override x.Initialize() =
          currentPath <- [| new PathEntry("No selection", Tag = null) |]
          ext := x.Document.GetContent<FSharpTextEditorCompletion>()
          x.Document.Editor.Caret.PositionChanged.Add(x.PathUpdated)
  
          //ext.TypeSegmentTreeUpdated += HandleTypeSegmentTreeUpdated;
      
      member private x.PathUpdated(e: Mono.TextEditor.DocumentLocationEventArgs) =
          match x.Document.ParsedDocument.Ast with
          | :? TypedParseResult as ast ->
              let loc = x.Document.Editor.Caret.Location
              let caretOffset = x.Document.Editor.Caret.Offset
  
              let posGt (p1Column, p1Line) (p2Column, p2Line) = 
                  (p1Line > p2Line || (p1Line = p2Line && p1Column > p2Column))
  
negative.code: 
              let toplevel = ast.Untyped.GetNavigationItems().Declarations
  
              #if DEBUG
              let allthings = [| for tl in  toplevel do yield (tl.Declaration.Name, tl.Nested |> Array.map (fun n -> n.Name)) |]
              #endif
  
              let topLevelTypesInsideCursor =
                  toplevel |> Array.filter (fun tl -> inside loc tl.Declaration.Range)
                           |> Array.sortBy(fun xs -> xs.Declaration.Range)
  
              let newPath = ResizeArray<_>()
              for top in topLevelTypesInsideCursor do
                  let name = top.Declaration.Name
                  if name.Contains(".") then
                      let nameparts = name.[.. name.LastIndexOf(".")]
                      newPath.Add(PathEntry(ImageService.GetPixbuf(ServiceUtils.getIcon top.Declaration.Glyph, Gtk.IconSize.Menu), x.GetEntityMarkup(top.Declaration), Tag = (ast, nameparts)))
                  else newPath.Add(PathEntry(ImageService.GetPixbuf(ServiceUtils.getIcon top.Declaration.Glyph, Gtk.IconSize.Menu), x.GetEntityMarkup(top.Declaration), Tag = ast))
              
              if topLevelTypesInsideCursor.Length > 0 then
                  let lastToplevel = topLevelTypesInsideCursor.Last()
                  //only first child found is returned, could there be multiple children found?
                  let child = lastToplevel.Nested |> Array.tryFind (fun tl -> inside loc tl.Range)
                  let multichild = lastToplevel.Nested |> Array.filter (fun tl -> inside loc tl.Range)
  
                  Debug.Assert( multichild.Length = 1, String.Format("{0} children found please investigate!", multichild.Length))
                  match child with
                  | Some(c) -> newPath.Add(PathEntry(ImageService.GetPixbuf(ServiceUtils.getIcon c.Glyph, Gtk.IconSize.Menu), x.GetEntityMarkup(c) , Tag = lastToplevel))
                  | None -> newPath.Add(PathEntry("No selection", Tag = lastToplevel))
  
              let previousPath = currentPath
              //ensure the path has chnaged from the previous one before setting and raising event.
              let samePath = Seq.forall2 (fun (p1:PathEntry) (p2:PathEntry) -> p1.Markup = p2.Markup) previousPath newPath
              if not samePath then
                  if newPath.Count = 0 then currentPath <- [|PathEntry("No selection", Tag = ast)|]
                  else currentPath <- newPath.ToArray()
  
                  //invoke pathChanged
                  pathChanged.Trigger(x, DocumentPathChangedEventArgs(previousPath))
          | _ -> ()
  
      override x.Dispose() =
          x.Document.Editor.Caret.PositionChanged.RemoveHandler(fun o e -> x.PathUpdated e)
          x.Document.DocumentParsed.RemoveHandler(fun o e -> x.PathUpdated null)
  
      interface IPathedDocument with
          member x.CurrentPath = currentPath
  