Skip to content

Commit d62a983

Browse files
Fix to token tagger
1 parent fbe0d14 commit d62a983

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ public StructureTagger(ITagAggregator<TokenTag>? tags) : base(tags)
3030

3131
public override IEnumerable<ITagSpan<IStructureTag>> GetTags(NormalizedSnapshotSpanCollection spans, bool isFullParse)
3232
{
33-
foreach (IMappingTagSpan<TokenTag> tag in Tags!.GetTags(spans).Where(t => t.Tag.SupportOutlining))
33+
foreach (IMappingTagSpan<TokenTag> tag in Tags!.GetTags(spans))
3434
{
35+
if (!tag.Tag.SupportOutlining || tag.Tag.GetOutliningText == null)
36+
{
37+
continue;
38+
}
39+
3540
NormalizedSnapshotSpanCollection tagSpans = tag.Span.GetSpans(tag.Span.AnchorBuffer.CurrentSnapshot);
3641

3742
foreach (SnapshotSpan tagSpan in tagSpans)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public TokenQuickInfo(ITagAggregator<TokenTag>? tags)
4646
SnapshotSpan span = new(triggerPoint.Value.Snapshot, triggerPoint.Value.Position, 0);
4747
IMappingTagSpan<TokenTag> tag = _tags.GetTags(span).FirstOrDefault(t => t.Tag.GetTooltipAsync != null);
4848

49-
if (tag != null && tag.Tag.GetTooltipAsync != null)
49+
if (tag != null && tag.Tag.HasTooltip && tag.Tag.GetTooltipAsync != null)
5050
{
5151
object? tooltip = await tag.Tag.GetTooltipAsync(triggerPoint.Value);
5252

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,21 @@ public class TokenTag : ITag
1515
/// <summary>
1616
/// Creates a new instance.
1717
/// </summary>
18-
public TokenTag(object tokenType, bool supportOutlining, Func<SnapshotPoint, Task<object>>? getTooltipAsync, params ErrorListItem[] errors)
18+
public TokenTag(object tokenType, bool supportOutlining, bool hasTooltip, params ErrorListItem[] errors)
1919
{
2020
TokenType = tokenType;
2121
SupportOutlining = supportOutlining;
22-
GetTooltipAsync = getTooltipAsync;
22+
HasTooltip = hasTooltip;
2323
Errors = errors;
2424
}
2525

2626
/// <summary>
2727
/// Creates a new instance.
2828
/// </summary>
2929
public TokenTag(object tokenType)
30-
: this(tokenType, false, null)
30+
: this(tokenType, false, false)
3131
{ }
3232

33-
/// <summary>
34-
/// Creates a new instance.
35-
/// </summary>
36-
public TokenTag(object tokenType, bool supportOutlining)
37-
: this(tokenType, supportOutlining, null)
38-
{ }
3933

4034
/// <summary>
4135
/// This can be any object you use to differentiate the type of token tags. It's used for classification.
@@ -45,12 +39,12 @@ public TokenTag(object tokenType, bool supportOutlining)
4539
/// <summary>
4640
/// Any tags supporting outlining will automatically get IStructure tags added.
4741
/// </summary>
48-
public virtual bool SupportOutlining { get; set; }
42+
public virtual bool SupportOutlining { get; }
4943

5044
/// <summary>
5145
/// Specify if the tag has any tooltip to show. When true, the GetTooltipAsync method will be called.
5246
/// </summary>
53-
public virtual bool HasTooltip { get; set; }
47+
public virtual bool HasTooltip { get; }
5448

5549
/// <summary>
5650
/// A list of errors associated with the tag.

0 commit comments

Comments
 (0)