diff --git a/src/Views/MergeConflictEditor.axaml.cs b/src/Views/MergeConflictEditor.axaml.cs index 1d2352dd..8c7b2621 100644 --- a/src/Views/MergeConflictEditor.axaml.cs +++ b/src/Views/MergeConflictEditor.axaml.cs @@ -351,8 +351,6 @@ namespace SourceGit.Views Models.TextMateHelper.SetThemeByApp(_textMate); else if (change.Property == SelectedChunkProperty) TextArea.TextView.InvalidateVisual(); - else if (change.Property == MaxLineNumberProperty) - TextArea.LeftMargins[0].InvalidateMeasure(); } private void UpdateContent() @@ -439,6 +437,9 @@ namespace SourceGit.Views return; } + foreach (var margin in TextArea.LeftMargins) + margin.InvalidateMeasure(); + var lines = Lines; var start = int.MaxValue; var count = 0; diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index d3b602c3..94940e74 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -98,6 +98,23 @@ namespace SourceGit.Views } } + protected override Size MeasureOverride(Size availableSize) + { + if (DataContext is not ViewModels.TextDiffContext ctx) + return new Size(0, 0); + + var typeface = new Typeface(TextArea.FontFamily); + var test = new FormattedText( + $"{ctx.Data.MaxLineNumber}", + CultureInfo.CurrentCulture, + FlowDirection.LeftToRight, + typeface, + TextArea.FontSize, + Brushes.White); + + return new Size(test.Width, 0); + } + private readonly bool _usePresenter; private readonly bool _isOld; } @@ -578,29 +595,6 @@ namespace SourceGit.Views protected override void OnDataContextChanged(EventArgs e) { base.OnDataContextChanged(e); - - if (DataContext is ViewModels.TextDiffContext ctx) - { - var typeface = new Typeface(FontFamily); - var test = new FormattedText( - $"{ctx.Data.MaxLineNumber}", - CultureInfo.CurrentCulture, - FlowDirection.LeftToRight, - typeface, - FontSize, - Brushes.White); - - var width = test.WidthIncludingTrailingWhitespace; - foreach (var margin in TextArea.LeftMargins) - { - if (margin is LineNumberMargin lineNumberMargin) - margin.Width = width; - } - - var dock = TextArea.FindDescendantOfType(); - dock?.InvalidateArrange(); - } - AutoScrollToFirstChange(); } @@ -721,6 +715,9 @@ namespace SourceGit.Views if (DataContext is not ViewModels.TextDiffContext ctx) return; + foreach (var margin in TextArea.LeftMargins) + margin.InvalidateMeasure(); + if (ctx.IsSideBySide() && !IsOld) return;