I have followed the steps here: http://msdn.microsoft.com/en-us/libr...code-snippet-2
to the tee and it works well ...
I want to change its functionality and highlight all of the comments and strings in the VS editor... so I modified it to this:
And...
And all works fine ... until some text is entered using the keyboard then all of the highlights disappear until the enter key is pressed...
Does anyone know why this may be happening?
Also here is a link to the project so you can easily see what's going on: http://i00Productions.org/TextAdornment1.zip
Thanks in advance,
Kris
to the tee and it works well ...
I want to change its functionality and highlight all of the comments and strings in the VS editor... so I modified it to this:
vb Code:
<Export(GetType(IViewTaggerProvider))> <ContentType("text")> <TagType(GetType(TextMarkerTag))> Friend Class HighlightWordTaggerProvider Implements IViewTaggerProvider <Import> _ Public Property Classifiers() As IClassifierAggregatorService Public Function CreateTagger(Of T As ITag)(ByVal textView As ITextView, ByVal buffer As ITextBuffer) As ITagger(Of T) Implements IViewTaggerProvider.CreateTagger 'provide highlighting only on the top buffer If textView.TextBuffer IsNot buffer Then Return Nothing End If Return TryCast(New HighlightWordTagger(Classifiers.GetClassifier(buffer)), ITagger(Of T)) End Function End Class
And...
vb Code:
Friend Class HighlightWordTagger Implements ITagger(Of HighlightWordTag) Public Property Classifier As IClassifier Public Function GetTags(spans As NormalizedSnapshotSpanCollection) As IEnumerable(Of ITagSpan(Of HighlightWordTag)) Implements ITagger(Of HighlightWordTag).GetTags If Classifier Is Nothing OrElse spans Is Nothing OrElse spans.Count = 0 Then Return Nothing End If Dim List = New List(Of TagSpan(Of HighlightWordTag))() For Each snapshotSpan In spans For Each ClassificationSpan As ClassificationSpan In Classifier.GetClassificationSpans(snapshotSpan) Dim name As String = ClassificationSpan.ClassificationType.Classification.ToLowerInvariant() If (name.Contains("comment") OrElse name.Contains("string")) AndAlso (name.Contains("xml") = False AndAlso name.Contains("doc") = False AndAlso name.Contains("tag") = False) Then List.Add(New TagSpan(Of HighlightWordTag)(ClassificationSpan.Span, New HighlightWordTag())) End If Next Next Return List End Function Public Sub New(Classifier As IClassifier) Me.Classifier = Classifier End Sub Public Event TagsChanged(sender As Object, e As SnapshotSpanEventArgs) Implements ITagger(Of HighlightWordTag).TagsChanged End Class
And all works fine ... until some text is entered using the keyboard then all of the highlights disappear until the enter key is pressed...
Does anyone know why this may be happening?
Also here is a link to the project so you can easily see what's going on: http://i00Productions.org/TextAdornment1.zip
Thanks in advance,
Kris