From 2f3f9387c4189375d900a4f05b24321b6367cd40 Mon Sep 17 00:00:00 2001 From: mika kuns Date: Fri, 7 Aug 2026 10:25:30 +0200 Subject: [PATCH] fix(diff): install background renderers on attach so themed brushes resolve --- .../Views/Controls/DiffTextView.axaml.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ClaudeDo.Ui/Views/Controls/DiffTextView.axaml.cs b/src/ClaudeDo.Ui/Views/Controls/DiffTextView.axaml.cs index 914cb3d7..21838697 100644 --- a/src/ClaudeDo.Ui/Views/Controls/DiffTextView.axaml.cs +++ b/src/ClaudeDo.Ui/Views/Controls/DiffTextView.axaml.cs @@ -69,17 +69,31 @@ public partial class DiffTextView : UserControl private ScrollViewer? _leftScroll, _rightScroll; private bool _scrollHooked; private bool _syncing; + private bool _renderersInstalled; public DiffTextView() { InitializeComponent(); _leftTm = LeftEditor.InstallTextMate(Registry); _rightTm = RightEditor.InstallTextMate(Registry); - InstallRenderers(); ReloadFile(); HookScrollSync(); } + /// Brushes and the mono typeface only resolve once the control is in the visual tree — + /// a detached control has no resource parent to walk up to, and its styles haven't been + /// applied yet. Installing the renderers in the constructor would freeze them on their + /// hardcoded fallbacks for good, since they capture their brushes once. + protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) + { + base.OnAttachedToVisualTree(e); + if (_renderersInstalled) return; + _renderersInstalled = true; + InstallRenderers(); + RebuildMargins(); + InvalidateRenderers(); + } + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) { base.OnPropertyChanged(change);