fix: avoid NRE

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-19 10:31:17 +08:00
parent 3be90b2ef6
commit f45bed6f92
No known key found for this signature in database

View file

@ -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<Models.TextDiffLine> 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)