Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit adbeb78

Browse files
committed
Added safeguards for edge cases
1 parent 87689e1 commit adbeb78

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎src/Views/TextDiffView.axaml.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,8 @@ public class SingleSideTextDiffPresenter : ThemedTextDiffPresenter
11461146

11471147
public void ForceSyncScrollOffset()
11481148
{
1149+
if (_scrollViewer == null)
1150+
return;
11491151
if (DataContext is ViewModels.TwoSideTextDiff diff)
11501152
diff.SyncScrollOffset = _scrollViewer?.Offset ?? Vector.Zero;
11511153
}
@@ -1585,11 +1587,13 @@ static TextDiffView()
15851587

15861588
CurrentChangeBlockIdxProperty.Changed.AddClassHandler<TextDiffView>((v, e) =>
15871589
{
1588-
if (v.Editor.Presenter != null)
1590+
if ((int)e.NewValue>=0&&v.Editor.Presenter != null)
15891591
{
15901592
foreach (var p in v.Editor.Presenter.GetVisualDescendants().OfType<ThemedTextDiffPresenter>())
15911593
{
15921594
p.JumpToChangeBlock((int)e.NewValue);
1595+
if (p is SingleSideTextDiffPresenter ssp)
1596+
ssp.ForceSyncScrollOffset();
15931597
}
15941598
}
15951599
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /