示例#1
0
 /// <summary>
 /// Remove the glyphs that are no long visible or covered by the <paramref name="newOrReformattedLines"/>.
 /// Refresh all the other the existing glyphs with the <paramref name="snapshot"/>.
 /// It should only be called by UI thread because UI elements are manipulated by this method.
 /// </summary>
 public void SetSnapshotAndUpdate(ITextSnapshot snapshot, IList <ITextViewLine> newOrReformattedLines, IList <ITextViewLine> translatedLines)
 {
     AssertIsForeground();
     if (!_glyphDataTree.IsEmpty())
     {
         // Go through all the existing visuals and invalidate or transform as appropriate.
         var allGlyphData = _glyphDataTree.ToImmutableArray();
         _glyphDataTree.ClearInPlace();
         foreach (var(span, glyph) in allGlyphData)
         {
             var newSpan = span.TranslateTo(snapshot, SpanTrackingMode.EdgeInclusive);
             if (!_textView.TextViewLines.IntersectsBufferSpan(newSpan) || GetStartingLine(newOrReformattedLines, newSpan) != null)
             {
                 //Either visual is no longer visible or it crosses a line
                 //that was reformatted.
                 _glyphsContainer.Children.Remove(glyph);
             }
             else
             {
                 _glyphDataTree.AddIntervalInPlace(new GlyphData(newSpan, glyph));
                 var line = GetStartingLine(translatedLines, newSpan);
                 if (line != null)
                 {
                     SetTop(line, glyph);
                 }
             }
         }
     }
 }