Skip to content

Commit f6e1e65

Browse files
committed
feature: add +/- in line number to indicate type of change (#593)
1 parent 06fd49b commit f6e1e65

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/Views/TextDiffView.axaml.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,32 @@ public override void Render(DrawingContext context)
105105
continue;
106106

107107
var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.LineMiddle) - view.VerticalOffset;
108+
109+
var prefix = null as FormattedText;
110+
if (info.Type == Models.TextDiffLineType.Added)
111+
{
112+
prefix = new FormattedText(
113+
"+",
114+
CultureInfo.CurrentCulture,
115+
FlowDirection.LeftToRight,
116+
typeface,
117+
presenter.FontSize,
118+
Brushes.Green);
119+
}
120+
else if (info.Type == Models.TextDiffLineType.Deleted)
121+
{
122+
prefix = new FormattedText(
123+
"-",
124+
CultureInfo.CurrentCulture,
125+
FlowDirection.LeftToRight,
126+
typeface,
127+
presenter.FontSize,
128+
Brushes.Red);
129+
}
130+
131+
if (prefix != null)
132+
context.DrawText(prefix, new Point(0, y - prefix.Height * 0.5));
133+
108134
var txt = new FormattedText(
109135
lineNumber,
110136
CultureInfo.CurrentCulture,
@@ -126,7 +152,7 @@ protected override Size MeasureOverride(Size availableSize)
126152
var maxLineNumber = presenter.GetMaxLineNumber();
127153
var typeface = TextView.CreateTypeface();
128154
var test = new FormattedText(
129-
$"{maxLineNumber}",
155+
$"- {maxLineNumber}",
130156
CultureInfo.CurrentCulture,
131157
FlowDirection.LeftToRight,
132158
typeface,

0 commit comments

Comments
 (0)