Skip to content
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
9 changes: 4 additions & 5 deletions src/VisualStudio/Core/Def/Venus/VenusCommandFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ protected override int GetDataTipTextImpl(TextSpan[] pSpan, out string pbstrText

// Next, we'll check to see if there is actually a DataTip for this candidate.
// If there is, we'll map this span back to the DataBuffer and return it.
pSpan[0] = candidateSpan.ToVsTextSpan();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

problem was here. we were placing a span in our subject-buffer coordinates into an in/out parameter that is referring to the surface buffer. If we ended up succeeding below, this wasn't a problem, as we'd overwrite this. But if we failed, we'd leave this bogus data in here.

var hr = base.GetDataTipTextImpl(_subjectBuffer, pSpan, out pbstrText);
var subjectBufferSpanData = new TextSpan[] { candidateSpan.ToVsTextSpan() };
var hr = GetDataTipTextImpl(_subjectBuffer, subjectBufferSpanData, out pbstrText);
if (ErrorHandler.Succeeded(hr))
{
var subjectSpan = _subjectBuffer.CurrentSnapshot.GetSpan(pSpan[0]);
var subjectSpan = _subjectBuffer.CurrentSnapshot.GetSpan(subjectBufferSpanData[0]);

// When mapping back up to the surface buffer, if we get more than one span,
// take the span that intersects with the input span, since that's probably
// the one we care about.
// If there are no such spans, just return.
var surfaceSpan = WpfTextView.BufferGraph.MapUpToBuffer(subjectSpan, SpanTrackingMode.EdgeInclusive, textViewModel.DataBuffer)
.SingleOrDefault(x => x.IntersectsWith(span));
.SingleOrDefault(x => x.IntersectsWith(span));

if (surfaceSpan == default)
{
Expand All @@ -92,7 +92,6 @@ protected override int GetDataTipTextImpl(TextSpan[] pSpan, out string pbstrText

// pSpan is an in/out parameter
pSpan[0] = surfaceSpan.ToVsTextSpan();

return hr;
}
}
Expand Down