fix(diff): install background renderers on attach so themed brushes resolve
This commit is contained in:
@@ -69,17 +69,31 @@ public partial class DiffTextView : UserControl
|
|||||||
private ScrollViewer? _leftScroll, _rightScroll;
|
private ScrollViewer? _leftScroll, _rightScroll;
|
||||||
private bool _scrollHooked;
|
private bool _scrollHooked;
|
||||||
private bool _syncing;
|
private bool _syncing;
|
||||||
|
private bool _renderersInstalled;
|
||||||
|
|
||||||
public DiffTextView()
|
public DiffTextView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_leftTm = LeftEditor.InstallTextMate(Registry);
|
_leftTm = LeftEditor.InstallTextMate(Registry);
|
||||||
_rightTm = RightEditor.InstallTextMate(Registry);
|
_rightTm = RightEditor.InstallTextMate(Registry);
|
||||||
InstallRenderers();
|
|
||||||
ReloadFile();
|
ReloadFile();
|
||||||
HookScrollSync();
|
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)
|
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
||||||
{
|
{
|
||||||
base.OnPropertyChanged(change);
|
base.OnPropertyChanged(change);
|
||||||
|
|||||||
Reference in New Issue
Block a user