Skip to content

Commit

Permalink
Merge pull request #273 from AvaloniaUI/fixes/foldingCrashes
Browse files Browse the repository at this point in the history
Attempt to prevent folding crashes
  • Loading branch information
danipen authored Oct 14, 2022
2 parents 0347e77 + 6ed2d53 commit 6159ad9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/AvaloniaEdit/Rendering/VisualLineText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructio
offset,
DocumentLength - relativeOffset);

var textSlice = new ReadOnlySlice<char>(text.Text.AsMemory(), text.Offset, text.Count, RelativeTextOffset);
var bufferOffset = RelativeTextOffset;

if (bufferOffset + text.Count > text.Text.Length)
{
bufferOffset = 0;
}

var textSlice = new ReadOnlySlice<char>(text.Text.AsMemory(), text.Offset, text.Count, bufferOffset);

return new TextCharacters(textSlice, TextRunProperties);
}
Expand Down

0 comments on commit 6159ad9

Please sign in to comment.