fix: virtual space not include (#364)

This commit is contained in:
leo 2024-08-16 19:21:48 +08:00
parent ed7465def5
commit a3496a9d2f
No known key found for this signature in database

View file

@ -183,31 +183,25 @@ namespace SourceGit.Views
var processingIdxEnd = 0; var processingIdxEnd = 0;
var nextHightlight = 0; var nextHightlight = 0;
var cloned = new List<Models.TextInlineRange>();
cloned.AddRange(info.Highlights);
foreach (var tl in line.TextLines) foreach (var tl in line.TextLines)
{ {
processingIdxEnd += tl.Length; processingIdxEnd += tl.Length;
var y = line.GetTextLineVisualYPosition(tl, VisualYPosition.LineTop) - textView.VerticalOffset; var y = line.GetTextLineVisualYPosition(tl, VisualYPosition.LineTop) - textView.VerticalOffset;
var height = line.GetTextLineVisualYPosition(tl, VisualYPosition.LineBottom) - textView.VerticalOffset - y; var h = line.GetTextLineVisualYPosition(tl, VisualYPosition.LineBottom) - textView.VerticalOffset - y;
while (nextHightlight < cloned.Count) while (nextHightlight < info.Highlights.Count)
{ {
var highlight = cloned[nextHightlight]; var highlight = info.Highlights[nextHightlight];
if (highlight.Start >= processingIdxEnd) if (highlight.Start >= processingIdxEnd)
{
processingIdxStart = processingIdxEnd;
break; break;
}
var start = highlight.Start < processingIdxStart ? processingIdxStart : highlight.Start; var start = line.GetVisualColumn(highlight.Start < processingIdxStart ? processingIdxStart : highlight.Start);
var end = highlight.End >= processingIdxEnd ? processingIdxEnd : highlight.End + 1; var end = line.GetVisualColumn(highlight.End >= processingIdxEnd ? processingIdxEnd : highlight.End + 1);
var x = line.GetTextLineVisualXPosition(tl, start) - textView.HorizontalOffset; var x = line.GetTextLineVisualXPosition(tl, start) - textView.HorizontalOffset;
var w = line.GetTextLineVisualXPosition(tl, end) - textView.HorizontalOffset - x; var w = line.GetTextLineVisualXPosition(tl, end) - textView.HorizontalOffset - x;
var rect = new Rect(x, y, w, height); var rect = new Rect(x, y, w, h);
drawingContext.DrawRectangle(highlightBG, null, rect); drawingContext.DrawRectangle(highlightBG, null, rect);
if (highlight.End >= processingIdxEnd) if (highlight.End >= processingIdxEnd)