From f45bed6f92d0f4f1c8b567ab11c78bdb8165c638 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 19 Nov 2024 10:31:17 +0800 Subject: [PATCH] fix: avoid NRE Signed-off-by: leo --- src/Views/TextDiffView.axaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index 242f8c4c..757690e8 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -1089,7 +1089,7 @@ namespace SourceGit.Views public void ForceSyncScrollOffset() { if (DataContext is ViewModels.TwoSideTextDiff diff) - diff.SyncScrollOffset = _scrollViewer.Offset; + diff.SyncScrollOffset = _scrollViewer?.Offset ?? Vector.Zero; } public override List GetLines() @@ -1302,7 +1302,7 @@ namespace SourceGit.Views private void OnTextViewScrollChanged(object sender, ScrollChangedEventArgs e) { if (TextArea.IsFocused && DataContext is ViewModels.TwoSideTextDiff diff) - diff.SyncScrollOffset = _scrollViewer.Offset; + diff.SyncScrollOffset = _scrollViewer?.Offset ?? Vector.Zero; } private void OnTextAreaPointerWheelChanged(object sender, PointerWheelEventArgs e)