From e7a4e68c5fb831b3e42c5af9cc83ebe1c00e1089 Mon Sep 17 00:00:00 2001 From: Shun-ichi Goto Date: Fri, 17 Apr 2026 17:14:56 +0900 Subject: [PATCH] fix: center diff change indicators and fix width calculation - Center the +/- indicators horizontally in the diff gutter - Use Math.Max(minus.Width, plus.Width) for accurate margin width instead of only measuring the '-' character --- src/Views/TextDiffView.axaml.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index d3b602c3a..1e75811db 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -155,7 +155,10 @@ public override void Render(DrawingContext context) } if (indicator != null) - context.DrawText(indicator, new Point(0, y - (indicator.Height * 0.5))); + { + var x = (Bounds.Width - indicator.Width) * 0.5; + context.DrawText(indicator, new Point(x, y - (indicator.Height * 0.5))); + } } } } @@ -167,14 +170,21 @@ protected override Size MeasureOverride(Size availableSize) return new Size(0, 0); var typeface = TextView.CreateTypeface(); - var test = new FormattedText( + var minus = new FormattedText( "-", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, presenter.FontSize, Brushes.White); - return new Size(test.Width, 0); + var plus = new FormattedText( + "+", + CultureInfo.CurrentCulture, + FlowDirection.LeftToRight, + typeface, + presenter.FontSize, + Brushes.White); + return new Size(Math.Max(minus.Width, plus.Width), 0); } protected override void OnDataContextChanged(EventArgs e)