From adbeb78ba3f314777ba2b8d1a425e7d60fb14d62 Mon Sep 17 00:00:00 2001 From: goran-w Date: Sat, 16 Nov 2024 13:31:39 +0100 Subject: [PATCH] Added safeguards for edge cases --- src/Views/TextDiffView.axaml.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index f6818722..5ccd9281 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -1146,6 +1146,8 @@ namespace SourceGit.Views public void ForceSyncScrollOffset() { + if (_scrollViewer == null) + return; if (DataContext is ViewModels.TwoSideTextDiff diff) diff.SyncScrollOffset = _scrollViewer?.Offset ?? Vector.Zero; } @@ -1585,11 +1587,13 @@ namespace SourceGit.Views CurrentChangeBlockIdxProperty.Changed.AddClassHandler((v, e) => { - if (v.Editor.Presenter != null) + if ((int)e.NewValue >= 0 && v.Editor.Presenter != null) { foreach (var p in v.Editor.Presenter.GetVisualDescendants().OfType()) { p.JumpToChangeBlock((int)e.NewValue); + if (p is SingleSideTextDiffPresenter ssp) + ssp.ForceSyncScrollOffset(); } } });