anchor.diff:      with exn -> None
   
     static member IsInteractiveAvailable =
  -    FSharpInteractivePad.Pad |> Option.isSome
  +    match FSharpInteractivePad.Pad with
  +    | Some(pad) -> match pad.Content with
  +                   | :? FSharpInteractivePad as fsipad -> fsipad.IsValidSession
  +                   | _ -> false
  +    | None -> false
   
     static member BringToFront(grabfocus) =
       FSharpInteractivePad.Pad |> Option.iter (fun pad -> pad.BringToFront(grabfocus))
  
positive.code:       if doc <> null then Path.GetDirectoryName(doc) |> Some else None
      else None
  
    let setupSession() = 
      let ses = InteractiveSession()
      let textReceived = ses.TextReceived.Subscribe(fun t -> view.WriteOutput t )
      let promptReady = ses.PromptReady.Subscribe(fun () -> view.Prompt true )
      ses.Exited.Add(fun e -> 
        textReceived.Dispose()
        promptReady.Dispose()
        if killIntent = NoIntent then
          DispatchService.GuiDispatch(fun () ->
            Debug.WriteLine (sprintf "Interactive: process stopped")
            view.WriteOutput("\nSession termination detected. Press Enter to restart."))
          isPrompting <- true
        elif killIntent = Restart then 
          DispatchService.GuiDispatch view.Clear
        killIntent <- NoIntent)
      ses.StartReceiving()
      // Make sure we're in the correct directory after a start/restart. No ActiveDocument event then.
      getCorrectDirectory() |> Option.iter (fun path -> ses.SendCommand("#silentCd @\"" + path + "\";;"))
      ses
      
    let session = ref (Some(setupSession()))
  
    let sendCommand (str:string) = 
       session := match !session with 
                  | None -> Some (setupSession())
                  | s -> s
       !session |> Option.iter (fun s -> s.SendCommand(str))
  
    let resetFsi intent = 
      killIntent <- intent
      !session |> Option.iter (fun ses -> ses.Kill())
      if intent = Restart then session := Some (setupSession())
    
    let AddSourceToSelection selection =
       let stap = IdeApp.Workbench.ActiveDocument.Editor.SelectionRange.Offset
  
negative.code:       view.Child.KeyPressEvent.Add(fun ea ->
          if ea.Event.State &&& ModifierType.ControlMask = ModifierType.ControlMask && ea.Event.Key = Key.period then
            !session |> Option.iter (fun s -> s.Interrupt()))
        if x.IsValidSession then
          activeDoc <- IdeApp.Workbench.ActiveDocumentChanged.Subscribe ensureCorrectDirectory |> Some
  
        x.UpdateFont()   
  
  