Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add virtual property TextMarkerTagType for SameWordHighLighterBase th… #365

Merged
merged 1 commit into from
Jul 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public class SameWordHighlighterBase : IViewTaggerProvider

[Import] internal ITextStructureNavigatorSelectorService? _textStructureNavigatorSelector = null;

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

internal class HighlightWordTag : TextMarkerTag
{
public HighlightWordTag() : base("MarkerFormatDefinition/HighlightWordFormatDefinition") { }
public HighlightWordTag(string tagName) : base(tagName) { }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep the default constructor to make it not break existing contracts?

}

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

// Second, yield all the other words in the file
foreach (SnapshotSpan span in NormalizedSnapshotSpanCollection.Overlap(spans, wordSpans))
{
yield return new TagSpan<HighlightWordTag>(span, new HighlightWordTag());
yield return new TagSpan<HighlightWordTag>(span, new HighlightWordTag(_tagger.TextMarkerTagType));
}
}

Expand Down