anchor.diff:                          false
                       elif currentText.Substring(textOffset).StartsWith("#endif") then
                           let span = EndIfBlockSpan()
  -                        if this.CurSpan <> null && typeof<AbstractBlockSpan>.IsAssignableFrom(this.CurSpan.GetType()) then
  +                        if this.CurSpan <> null && this.CurSpan :? AbstractBlockSpan then
                               this.FoundSpanEnd.Invoke(this.CurSpan, i, 0)
                           this.FoundSpanBegin.Invoke(span, i, 6)
                           this.FoundSpanEnd.Invoke(span, i + 6, 0)
  +                        i <- i + 6
                           true
                       elif (this.CurSpan = null || (this.CurSpan <> null && this.CurSpan.Color <> "Excluded Code")) then
                           let spanLength = 
                               match currentText.Substring(textOffset).IndexOf(Environment.NewLine) with
                               | -1 -> currentText.Substring(textOffset).Length
                               | value -> value
  -                        this.FoundSpanBegin.Invoke(PreprocessorSpan(), i + textOffset, spanLength)
  -                        i <- i + spanLength
  -                        base.ScanSpan(&i)
  +                        let span = PreprocessorSpan()
  +                        this.FoundSpanBegin.Invoke(span, i, len)
  +                        this.FoundSpanEnd.Invoke(span, i + endIdx, 0)
  +                        i <- i + endIdx
  +                        true
                       else
                           false
                   elif (this.CurSpan <> null && this.CurSpan.Color <> "Excluded Code") then
  
positive.code:         if ts.TokenInfo.ColorClass = FSharpTokenColorKind.InactiveCode then Some UnusedCode
          else None
  
      let isAbstractBlockSpan (span: Span) = span.Rule = ""
  
      let lineStartsWithAbstractBlockSpan (spanStack: CloneableStack<Span>) =
          if spanStack = null || spanStack.Count = 0 then false
          else
              let headSpan = spanStack.Peek()
              headSpan |> isAbstractBlockSpan
  
      let containsAbstractBlockSpan (spanStack: CloneableStack<Span>) =
          if (spanStack = null) then false
          else
              let cloned = spanStack.Clone()
              cloned
              |> List.ofSeq
              |> List.exists isAbstractBlockSpan
  
      let getAbstractBlockSpan (spanStack: CloneableStack<Span>) =
          let cloned = spanStack.Clone()
          cloned
          |> Seq.find isAbstractBlockSpan :?> FSharpSyntaxModeInternals.AbstractBlockSpan
  
      let hasSpans (line: DocumentLine) =
          line <> null && line.StartSpan <> null && line.StartSpan.Count > 0
  
      let (|ExcludedCode|StringCode|CommentCode|OtherCode|) (document: TextDocument, line: DocumentLine, offset, length, style: Highlighting.ColorScheme) =
          let docText = document.GetTextAt(offset, length)
          if hasSpans(line) then
              if not (lineStartsWithAbstractBlockSpan line.StartSpan)  then
                  if (containsAbstractBlockSpan line.StartSpan) && (getAbstractBlockSpan line.StartSpan).Disabled  then
                      ExcludedCode style.ExcludedCode.Name else
                  match line.StartSpan.Peek() with
                  | span when span.Rule = "String" || span.Rule = "VerbatimString" || span.Rule = "TripleQuotedString" ->
                      StringCode span.Color
                  | span when span.Rule = "Comment" || span.Rule = "MultiComment" ->
                      CommentCode span.Color
                  | _ -> OtherCode (style.PlainText.Name, docText)
              elif containsAbstractBlockSpan line.StartSpan &&
                 (getAbstractBlockSpan line.StartSpan).Disabled then
                  ExcludedCode style.ExcludedCode.Name
              else
                  OtherCode (style.PlainText.Name, docText)
          else OtherCode (style.PlainText.Name, docText)
  
  module internal Rules =
      let baseMode =
  
negative.code:                 this.setColor()
  
      type EndIfBlockSpan() =
          inherit AbstractBlockSpan(Color = "Preprocessor", Rule = "PreProcessorComment")
  
      type IfBlockSpan() =
          inherit AbstractBlockSpan()
  
      type ElseBlockSpan() =
          inherit AbstractBlockSpan()
  
      let containsFunctionDef (subText : string) =
          let endOfBlockDef = subText.IndexOf( '*')
          subText.IndexOf ( ')', endOfBlockDef) <> -1
  
      type FSharpSpanParser(mode:SyntaxMode, spanStack, defines: string list) =
          inherit SyntaxMode.SpanParser(mode, spanStack)
  
          member private this.ScanPreProcessorElse(i: byref<int>) =
              if not (spanStack |> Seq.exists (fun span -> span :? IfBlockSpan)) then
                  i <- i + "#else".Length
  
              let elseBlockSpan = ElseBlockSpan()
              if this.CurSpan <> null && this.CurSpan :? AbstractBlockSpan then
                  elseBlockSpan.Disabled <- not (this.CurSpan :?> AbstractBlockSpan).Disabled
                  this.FoundSpanEnd.Invoke(this.CurSpan, i, 0)
              this.FoundSpanBegin.Invoke(elseBlockSpan, i , "#else".Length)
  