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);