anchor.diff:              let output =
                   try 
                       let result =
  -                        trimIfNeeded doc.Editor.Text (CodeFormatter.formatSourceString isFsiFile input config)
  +                        trimIfNeeded input (CodeFormatter.formatSourceString isFsiFile input config)
                       //If onTheFly do the replacements in the document
  -                    if onTheFly then doc.Editor.Document.Replace(0, input.Length, result)
  +                    doc |> Option.iter (fun d -> d.Editor.Document.Replace(0, input.Length, result))
                       result
                   with exn -> 
                       LoggingService.LogError("Error occured: {0}", exn.Message)
  
positive.code:                     LoggingService.LogInfo("**Fantomas**: Try to format range {0}.", range)
                      let! result = 
                          try 
                              let result = 
                                   trimIfNeeded (doc.Editor.GetTextBetween(fromOffset, toOffset+1)) 
                                                (CodeFormatter.formatSelectionOnly isFsiFile range input config)
                              if onTheFly then 
                                  //If onTheFly do the replacements in the document
                                  let selection = doc.Editor.GetTextBetween(fromOffset, toOffset+1)
                                  doc.Editor.Document.Replace(fromOffset, selection.Length, result)
                                  None
                              else Some(result)
                           with exn -> 
  
negative.code:             | Some newCode -> newCode
              | None -> null
  
      let formatText (doc : Gui.Document option) (policyParent : PolicyContainer) (mimeTypeInheritanceChain : string seq) input formattingOption = 
          let textStylePolicy = policyParent.Get<TextStylePolicy>(mimeTypeInheritanceChain)
          let formattingPolicy = policyParent.Get<FSharpFormattingPolicy>(mimeTypeInheritanceChain)
          format doc textStylePolicy formattingPolicy input formattingOption
  