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:                 yield! attrListRange
                  yield! parseExpr hd.ArgExpr
                  // If there are more than 2 attributes only add tags to the 2nd and beyond, to avoid double collapsing on the first attribute
                  yield! tl |> Seq.collect (fun attr -> rcheck Scope.Attribute Collapse.Same <| Range.startToEnd attr.Range attr.ArgExpr.Range)
                  // visit the expressions inside each attribute
                  yield! attrs |> Seq.collect (fun attr -> parseExpr attr.ArgExpr)
          }
  
      and private parseBinding (Binding (_,kind,_,_,attrs,_,_,_,_,e,br,_) as b) =
          seq {
  //            let r = Range.endToEnd b.RangeOfBindingSansRhs b.RangeOfBindingAndRhs
              match kind with
              | SynBindingKind.NormalBinding ->
                  yield! rcheck Scope.LetOrUse Collapse.Below <| Range.endToEnd b.RangeOfBindingSansRhs b.RangeOfBindingAndRhs
              | SynBindingKind.DoBinding ->
                  yield! rcheck Scope.Do Collapse.Below <| Range.modStart br 2
              | _ -> ()
              yield! parseAttributes attrs
              yield! parseExpr e
          }
  
      and private parseBindings = Seq.collect parseBinding
  
      and private parseSynMemberDefn d =
          seq {
              match d with
              | SynMemberDefn.Member (binding, r) ->
                  yield! rcheck Scope.Member Collapse.Below r
                  yield! parseBinding binding
              | SynMemberDefn.LetBindings (bindings, _, _, _r) ->
                  //yield! rcheck Scope.LetOrUse Collapse.Below r
                  yield! parseBindings bindings
              | SynMemberDefn.Interface (tp,iMembers,_) ->
                  yield! rcheck Scope.Interface Collapse.Below <| Range.endToEnd tp.Range d.Range
                  match iMembers with
                  | Some members -> yield! Seq.collect parseSynMemberDefn members
                  | None -> ()
              | SynMemberDefn.NestedType (td, _, _) ->
                  yield! parseTypeDefn td
              | SynMemberDefn.AbstractSlot (ValSpfn(_, _, _, synt, _, _, _, _, _, _, _), _, r) ->
                  yield! rcheck Scope.Member Collapse.Below <| Range.startToEnd synt.Range r
              | SynMemberDefn.AutoProperty (_, _, _, _, (*memkind*)_, _, _, _, e, _, r) ->
                  yield! rcheck Scope.Member Collapse.Below r
                  yield! parseExpr e
              | _ -> ()
          }
  
negative.code:                     yield! parseExpr e
                  yield! recordFields |> (Seq.choose (fun (_,e,_) -> e) >> Seq.collect parseExpr)
                  // exclude the opening `{` and closing `}` of the record from collapsing
                  yield! rcheck Scope.Record Collapse.Same r <| Range.modBoth 1 1 r
              | _ -> ()
          }
  
      and private parseMatchClause (SynMatchClause.Clause(synPat,_,e,_r,_) as clause) =
          let rec getLastPat = function
              | SynPat.Or(_, pat, _) -> getLastPat pat
              | x -> x
  
          seq {
              let synPat = getLastPat synPat
              let collapse  = Range.endToEnd synPat.Range clause.Range // Collapse the scope starting with `->`
              yield! rcheck Scope.MatchClause Collapse.Same e.Range collapse
              yield! parseExpr e
          }
  
      and private parseMatchClauses = Seq.collect parseMatchClause
  
  