diff --git a/src/EditorFeatures/Core.Wpf/Adornments/AbstractAdornmentManager.cs b/src/EditorFeatures/Core.Wpf/Adornments/AbstractAdornmentManager.cs index fdd62dda05303..ced60fb3c0f4b 100644 --- a/src/EditorFeatures/Core.Wpf/Adornments/AbstractAdornmentManager.cs +++ b/src/EditorFeatures/Core.Wpf/Adornments/AbstractAdornmentManager.cs @@ -277,7 +277,7 @@ protected bool ShouldDrawTag(SnapshotSpan snapshotSpan, IMappingTagSpan mappi protected SnapshotPoint? GetMappedPoint(SnapshotSpan snapshotSpan, IMappingTagSpan mappingTagSpan) { - var point = mappingTagSpan.Span.Start.GetPoint(snapshotSpan.Snapshot, PositionAffinity.Predecessor); + var point = mappingTagSpan.Span.End.GetPoint(snapshotSpan.Snapshot, PositionAffinity.Predecessor); if (point == null) { return null; diff --git a/src/EditorFeatures/Core.Wpf/InlineDiagnostics/InlineDiagnosticsAdornmentManager.cs b/src/EditorFeatures/Core.Wpf/InlineDiagnostics/InlineDiagnosticsAdornmentManager.cs index 929e599b576bb..31f53051f221b 100644 --- a/src/EditorFeatures/Core.Wpf/InlineDiagnostics/InlineDiagnosticsAdornmentManager.cs +++ b/src/EditorFeatures/Core.Wpf/InlineDiagnostics/InlineDiagnosticsAdornmentManager.cs @@ -116,47 +116,6 @@ private TextFormattingRunProperties GetFormat(IClassificationType classification return _formatMap.GetTextProperties(classificationType); } - /// - /// Get the spans located on each line so that it can only display the first one that appears on the line - /// - private void AddSpansOnEachLine(NormalizedSnapshotSpanCollection changedSpanCollection, - Dictionary> map) - { - var viewLines = TextView.TextViewLines; - - foreach (var changedSpan in changedSpanCollection) - { - if (!viewLines.IntersectsBufferSpan(changedSpan)) - { - continue; - } - - var tagSpans = TagAggregator.GetTags(changedSpan); - foreach (var tagMappingSpan in tagSpans) - { - if (!ShouldDrawTag(changedSpan, tagMappingSpan, out var mappedPoint)) - { - continue; - } - - // mappedPoint is known to not be null here because it is checked in the ShouldDrawTag method call. - var lineNum = mappedPoint.GetContainingLine().LineNumber; - - // If the line does not have an associated tagMappingSpan and changedSpan, then add the first one. - if (!map.TryGetValue(lineNum, out var value)) - { - map.Add(lineNum, tagMappingSpan); - } - else if (value.Tag.ErrorType is not PredefinedErrorTypeNames.SyntaxError && tagMappingSpan.Tag.ErrorType is PredefinedErrorTypeNames.SyntaxError) - { - // Draw the first instance of an error, if what is stored in the map at a specific line is - // not an error, then replace it. Otherwise, just get the first warning on the line. - map[lineNum] = tagMappingSpan; - } - } - } - } - /// /// Iterates through the mapping of line number to span and draws the diagnostic in the appropriate position on the screen, /// as well as adding the tag to the adornment layer. @@ -238,5 +197,46 @@ protected override void AddAdornmentsToAdornmentLayer_CallOnlyOnUIThread(Normali removedCallback: delegate { graphicsResult.Dispose(); }); } } + + /// + /// Get the spans located on each line so that it can only display the first one that appears on the line + /// + private void AddSpansOnEachLine(NormalizedSnapshotSpanCollection changedSpanCollection, + Dictionary> map) + { + var viewLines = TextView.TextViewLines; + + foreach (var changedSpan in changedSpanCollection) + { + if (!viewLines.IntersectsBufferSpan(changedSpan)) + { + continue; + } + + var tagSpans = TagAggregator.GetTags(changedSpan); + foreach (var tagMappingSpan in tagSpans) + { + if (!ShouldDrawTag(changedSpan, tagMappingSpan, out var mappedPoint)) + { + continue; + } + + // mappedPoint is known to not be null here because it is checked in the ShouldDrawTag method call. + var lineNum = mappedPoint.GetContainingLine().LineNumber; + + // If the line does not have an associated tagMappingSpan and changedSpan, then add the first one. + if (!map.TryGetValue(lineNum, out var value)) + { + map.Add(lineNum, tagMappingSpan); + } + else if (value.Tag.ErrorType is not PredefinedErrorTypeNames.SyntaxError && tagMappingSpan.Tag.ErrorType is PredefinedErrorTypeNames.SyntaxError) + { + // Draw the first instance of an error, if what is stored in the map at a specific line is + // not an error, then replace it. Otherwise, just get the first warning on the line. + map[lineNum] = tagMappingSpan; + } + } + } + } } }