Skip to content

Commit

Permalink
Merge pull request #61567 from akhera99/bugs/fix_inline_hints_tagger
Browse files Browse the repository at this point in the history
InlineHintsTagger: Fix assumption that GetSpans will retrieve a length greater than 0
  • Loading branch information
akhera99 authored May 31, 2022
2 parents efafad4 + 8d04e5d commit 508f4b4
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/EditorFeatures/Core.Wpf/InlineHints/InlineHintsTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,23 @@ public IEnumerable<ITagSpan<IntraTextAdornmentTag>> GetTags(NormalizedSnapshotSp
var selectedSpans = new List<ITagSpan<IntraTextAdornmentTag>>();
for (var i = 0; i < _cache.Count; i++)
{
var tagSpan = _cache[i].mappingTagSpan.Span.GetSpans(snapshot)[0];
if (spans.IntersectsWith(tagSpan))
var tagSpans = _cache[i].mappingTagSpan.Span.GetSpans(snapshot);
if (tagSpans.Count == 1)
{
if (_cache[i].tagSpan is not { } hintTagSpan)
var tagSpan = tagSpans[0];
if (spans.IntersectsWith(tagSpan))
{
var hintUITag = InlineHintsTag.Create(
_cache[i].mappingTagSpan.Tag.Hint, Format, _textView, tagSpan, _taggerProvider, _formatMap, classify);
if (_cache[i].tagSpan is not { } hintTagSpan)
{
var hintUITag = InlineHintsTag.Create(
_cache[i].mappingTagSpan.Tag.Hint, Format, _textView, tagSpan, _taggerProvider, _formatMap, classify);

hintTagSpan = new TagSpan<IntraTextAdornmentTag>(tagSpan, hintUITag);
_cache[i] = (_cache[i].mappingTagSpan, hintTagSpan);
}
hintTagSpan = new TagSpan<IntraTextAdornmentTag>(tagSpan, hintUITag);
_cache[i] = (_cache[i].mappingTagSpan, hintTagSpan);
}

selectedSpans.Add(hintTagSpan);
selectedSpans.Add(hintTagSpan);
}
}
}

Expand Down

0 comments on commit 508f4b4

Please sign in to comment.