anchor.diff:              | _ -> ()
           }
   
  -    let private parseModuleOrNamespace moduleOrNs =
  -        seq { let (SynModuleOrNamespace.SynModuleOrNamespace (_,_,_,decls,_,_,_,_)) = moduleOrNs
  -              yield! collectHashDirectives decls
  -              yield! collectOpens decls
  -              yield! Seq.collect parseDeclaration decls }
  +    let private parseModuleOrNamespace (SynModuleOrNamespace.SynModuleOrNamespace (longId,_,isModule,decls,_,attribs,_,r)) =
  +        seq {
  +            yield! parseAttributes attribs
  +            let idRange = longIdentRange longId
  +            let fullrange = Range.startToEnd idRange r  
  +            let collapse = Range.endToEnd idRange r 
  +            if isModule then
  +                yield! rcheck Scope.Module Collapse.Below fullrange collapse
  +
  +            yield! collectHashDirectives decls
  +            yield! collectOpens decls
  +            yield! Seq.collect parseDeclaration decls
  +        }
   
       type private LineNum = int
       type private LineStr = string
  -    type private CommentType = Regular | XmlDoc
  -    
  +    type private CommentType = SingleLine | XmlDoc
  +
       [<NoComparison>]
  -    type private CommentList = 
  +    type private CommentList =
           { Lines: ResizeArray<LineNum * LineStr>
             Type: CommentType }
  -        static member New ty lineStr = 
  +        static member New ty lineStr =
               { Type = ty; Lines = ResizeArray [| lineStr |] }
   
  -    let private (|Comment|_|) line =
  -        match line with
  -        | String.StartsWith "///" -> Some XmlDoc
  -        | String.StartsWith "//" -> Some Regular
  -        | _ -> None
  +    /// Determine if a line is a single line or xml docummentation comment
  +    let private (|Comment|_|) (line: string) =
  +        if line.StartsWith "///" then Some XmlDoc
  +        elif line.StartsWith "//" then Some SingleLine
  +        else None
   
       let getCommentRanges (lines: string[]) =
  -        let comments: CommentList list =
  -            lines
  -            |> Array.foldi (fun ((lastLineNum, currentComment: CommentList option, result) as state) lineNum lineStr ->
  +        let rec loop ((lastLineNum, currentComment: CommentList option, result) as state) (lines: string list) lineNum =
  +            match lines with
  +            | [] -> state
  +            | lineStr :: rest ->
                   match lineStr.TrimStart(), currentComment with
                   | Comment commentType, Some comment ->
  -                    if comment.Type = commentType && lineNum = lastLineNum + 1 then
  -                        comment.Lines.Add (lineNum, lineStr)
  -                        lineNum, currentComment, result
  -                    else lineNum, Some (CommentList.New commentType (lineNum, lineStr)), comment :: result
  -                | Comment commentType, None -> 
  -                    lineNum, Some (CommentList.New commentType (lineNum, lineStr)), result
  -                | _, Some comment -> 
  -                    lineNum, None, comment :: result
  -                | _ -> state) 
  -               (-1, None, [])
  -            |> fun (_, lastComment, comments) -> 
  -                match lastComment with 
  -                | Some comment -> 
  -                    comment :: comments 
  +                    loop(
  +                        if comment.Type = commentType && lineNum = lastLineNum + 1 then
  +                            comment.Lines.Add (lineNum, lineStr)
  +                            lineNum, currentComment, result
  +                        else lineNum, Some (CommentList.New commentType (lineNum, lineStr)), comment :: result) rest (lineNum + 1)
  +                | Comment commentType, None ->
  +                    loop(lineNum, Some (CommentList.New commentType (lineNum, lineStr)), result) rest (lineNum + 1)
  +                | _, Some comment ->
  +                    loop(lineNum, None, comment :: result) rest (lineNum + 1)
  +                | _ -> loop(lineNum, None, result) rest (lineNum + 1)
  +
  +        let comments: CommentList list =
  +            loop (-1, None, []) (List.ofArray lines) 0
  +            |> fun (_, lastComment, comments) ->
  +                match lastComment with
  +                | Some comment ->
  +                    comment :: comments
                   | _ -> comments
                   |> List.rev
   
  
positive.code:                 Some (Range.mkRange "" (Range.mkPos r.StartLine prefixLength) r.End)
              | _ -> None) Scope.HashDirective
  
  
      let rec private parseDeclaration (decl: SynModuleDecl) =
          seq {
              match decl with
              | SynModuleDecl.Let (_,bindings,_) ->
                  yield! parseBindings bindings
              | SynModuleDecl.Types (types,_) ->
                  yield! Seq.collect parseTypeDefn types
              // Fold the attributes above a module
              | SynModuleDecl.NestedModule (SynComponentInfo.ComponentInfo (attrs,_,_,_,_,_,_,cmpRange),_, decls,_,_) ->
                  // Outline the full scope of the module
                  yield! rcheck Scope.Module Collapse.Below <| Range.endToEnd cmpRange decl.Range
                  // A module's component info stores the ranges of its attributes
                  yield! parseAttributes attrs
                  yield! collectOpens decls
  
negative.code:             match ranges with
              | [] -> None
              | [r] when r.StartLine = r.EndLine -> None
              | [r] ->
                  let range = Range.mkRange "" r.Start r.End
                  Some { Scope = scope; Collapse = Collapse.Same; Range = range ; CollapseRange = range }
              | lastRange :: rest ->
                  let firstRange = Seq.last rest
                  let range = Range.mkRange "" firstRange.Start lastRange.End
                  Some { Scope = scope; Collapse = Collapse.Same; Range = range; CollapseRange = range }
  
          decls |> (List.choose predicate >> groupConsecutiveDecls >> List.choose selectRanges)
  
      let collectOpens = getConsecutiveModuleDecls (function SynModuleDecl.Open (_, r) -> Some r | _ -> None) Scope.Open
  
  