anchor.diff:  /// Format a part of source string using given config, and return the (formatted) selected part only.
   let formatSelectionOnly isFsiFile (r : range) (s : string) config =
       let lines = split s
  -    formatRange false isFsiFile r.StartLine r.StartColumn r.EndLine r.EndColumn lines s config
  -    
  +    formatRange false isFsiFile r lines s config
  +
  + /// Format a selected part of source string using given config; expanded selected ranges to parsable ranges. 
  +let formatSelectionExpanded isFsiFile (r : range) (s : string) config =
  +    let lines = split s
  +    let sourceTokenizer = SourceTokenizer([], "/tmp.fsx")
  +
  +    // Move to the section with real contents
  +    let contentRange =
  +        if r.StartLine = r.EndLine then r
  +        else
  +            let startLine = getStartLineIndex lines (r.StartLine - 1) + 1
  +            let endLine = getEndLineIndex lines (r.EndLine - 1) + 1
  +            // Notice that Line indices start at 1 while Column indices start at 0.
  +            makeRange startLine 0 endLine (lines.[endLine-1].Length - 1)
  +
  +    let startTokenizer = sourceTokenizer.CreateLineTokenizer(lines.[contentRange.StartLine-1])
  +
  +    let startCol = getStartCol contentRange startTokenizer (ref 0L)
  +
  +    let endTokenizer =
  +        if contentRange.StartLine = contentRange.EndLine then startTokenizer 
  +        else sourceTokenizer.CreateLineTokenizer(lines.[contentRange.EndLine-1])
  +
  +    let endCol = getEndCol contentRange endTokenizer (ref 0L)
  +
  +    let expandedRange = makeRange contentRange.StartLine startCol contentRange.EndLine endCol
  +    (formatRange true isFsiFile expandedRange lines s config, expandedRange)    
  +   
   /// Format a selected part of source string using given config; keep other parts unchanged. 
   let formatSelectionFromString isFsiFile (r : range) (s : string) config =
  -    let lines = split s
  -    let sourceToken = SourceTokenizer([], "/tmp.fsx")
  -
  -    // Move to the section with real contents
  -    let r =
  -        if r.StartLine = r.EndLine then r
  -        else
  -            let startLine = getStartLine lines (r.StartLine - 1)
  -            let endLine = getEndLine lines (r.EndLine - 1) 
  -            // Notice that Line indices start at 1 while Column indices start at 0.
  -            makeRange (startLine + 1) 0 (endLine + 1) (lines.[endLine].Length - 1)
  -
  -    let startTokenizer = sourceToken.CreateLineTokenizer(lines.[r.StartLine-1])
  -
  -    let startCol = getStartCol r startTokenizer (ref 0L)
  -
  -    let endTokenizer =
  -        if r.StartLine = r.EndLine then startTokenizer 
  -        else sourceToken.CreateLineTokenizer(lines.[r.EndLine-1])
  -
  -    let endCol = getEndCol r endTokenizer (ref 0L)
  -    formatRange true isFsiFile r.StartLine startCol r.EndLine endCol lines s config    
  +    fst (formatSelectionExpanded isFsiFile r s config)
   
   type internal BlockType =
      | List
  
positive.code:             if pos >= s.Length then s.Length - 1 else pos 
          (start, finish)
  
      let range = makeRange startLine startCol endLine endCol
      let (start, finish) = stringPos range
      let pre = if start = 0 || not replaceDocument then "" else s.[0..start-1]
  
  
negative.code:         let pattern = if patch = RecType then Regex("type") else Regex("let rec")
          let formatteds = split (pattern.Replace(result, "and", 1))
          reconstructSourceCode startCol formatteds pre post
      | Nothing ->
          let result = formatSelection isFsiFile selection config
          let formatteds = split result
          reconstructSourceCode startCol formatteds pre post
  