Skip to content

Commit

Permalink
Merge pull request #73435 from DoctorKrolic/raw-string-guide-line-pla…
Browse files Browse the repository at this point in the history
…cement
  • Loading branch information
CyrusNajmabadi committed May 13, 2024
2 parents 1e0edc4 + 63b6d15 commit ccf960d
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,21 @@ private VisibleBlock(double x, ImmutableArray<(double start, double end)> ySegme
if (span.End.GetContainingLine().Start == span.End)
return null;

// We want to draw the line right before the quote character. So -1 to get that character's position.
// Horizontally position the adornment in the center of the character. This position could actually be
// 0 if the entire doc is deleted and we haven't recomputed the updated tags yet. So be resilient for
// the position being out of bounds.
// This position could actually be 0 if the entire doc is deleted
// and we haven't recomputed the updated tags yet. So be resilient
// for the position being out of bounds.
if (span.End == 0)
return null;

// We want to draw the line right before the quote character. So -1 to get that character's position.
// If we position the adornment right at the end of that character it will visually merge with the
// text, so we want to back it off a little bit to the left. Half of a virtual space is gonna do the trick.
// It is important to keep this value independent of what space character is used to avoid visual bugs
// like https://github.com/dotnet/roslyn/issues/64230
var bufferPosition = span.End - 1;
var anchorPointLine = view.GetTextViewLineContainingBufferPosition(bufferPosition);
var bounds = anchorPointLine.GetCharacterBounds(bufferPosition);
var x = Math.Floor((bounds.Left + bounds.Right) * 0.5);
var x = Math.Floor(bounds.Right - (anchorPointLine.VirtualSpaceWidth / 2));

var firstLine = view.TextViewLines.FirstVisibleLine;
var lastLine = view.TextViewLines.LastVisibleLine;
Expand Down

0 comments on commit ccf960d

Please sign in to comment.