Skip to content

Commit f5d1789

Browse files
Merge pull request #365 from X-Sharp/master
Add virtual property TextMarkerTagType for SameWordHighLighterBase th…
2 parents f1c02be + 6e37c92 commit f5d1789

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/toolkit/Community.VisualStudio.Toolkit.Shared/MEF/SameWordHighlighterBase.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public class SameWordHighlighterBase : IViewTaggerProvider
1919

2020
[Import] internal ITextStructureNavigatorSelectorService? _textStructureNavigatorSelector = null;
2121

22+
/// <summary>
23+
/// Return the tag name for the HighlightWord tags. Defaults to "MarkerFormatDefinition/HighlightWordFormatDefinition".
24+
/// Can be overwritten in a subclass to change the format of the tags.
25+
/// </summary>
26+
public virtual string TextMarkerTagType => "MarkerFormatDefinition/HighlightWordFormatDefinition";
2227
/// <summary>
2328
/// The Options that are used to find the matching words. The default implementation returns
2429
/// FindOptions.WholeWord | FindOptions.MatchCase
@@ -50,7 +55,7 @@ public ITagger<T> CreateTagger<T>(ITextView textView, ITextBuffer buffer) where
5055

5156
internal class HighlightWordTag : TextMarkerTag
5257
{
53-
public HighlightWordTag() : base("MarkerFormatDefinition/HighlightWordFormatDefinition") { }
58+
public HighlightWordTag(string tagName) : base(tagName) { }
5459
}
5560

5661
internal class SameWordHighlighterTagger : ITagger<HighlightWordTag>, IDisposable
@@ -190,13 +195,13 @@ public IEnumerable<ITagSpan<HighlightWordTag>> GetTags(NormalizedSnapshotSpanCol
190195
// the duplication here is expected.
191196
if (spans.OverlapsWith(new NormalizedSnapshotSpanCollection(currentWord)))
192197
{
193-
yield return new TagSpan<HighlightWordTag>(currentWord, new HighlightWordTag());
198+
yield return new TagSpan<HighlightWordTag>(currentWord, new HighlightWordTag(_tagger.TextMarkerTagType));
194199
}
195200

196201
// Second, yield all the other words in the file
197202
foreach (SnapshotSpan span in NormalizedSnapshotSpanCollection.Overlap(spans, wordSpans))
198203
{
199-
yield return new TagSpan<HighlightWordTag>(span, new HighlightWordTag());
204+
yield return new TagSpan<HighlightWordTag>(span, new HighlightWordTag(_tagger.TextMarkerTagType));
200205
}
201206
}
202207

0 commit comments

Comments
 (0)