From b72f7013249a5047c2613d4fb9cb19e2c1ac9df1 Mon Sep 17 00:00:00 2001 From: goran-w Date: Sat, 16 Nov 2024 18:39:04 +0100 Subject: [PATCH] The 2 implementations can now be switched Added a bool property DiffView.UseChangeBlocks. It's not bound from UI yet, but could be used for runtime switching between the two different implementations of prev/next change. The buttons are now using the OnGoto[Prev|Next]Change Click-handler, regardless of implementation. --- src/Views/DiffView.axaml.cs | 46 ++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/src/Views/DiffView.axaml.cs b/src/Views/DiffView.axaml.cs index 7184ec44..7f7c91f2 100644 --- a/src/Views/DiffView.axaml.cs +++ b/src/Views/DiffView.axaml.cs @@ -11,30 +11,48 @@ namespace SourceGit.Views InitializeComponent(); } + public bool UseChangeBlocks { get; set; } = true; + private void OnGotoPrevChange(object _, RoutedEventArgs e) { - var textDiff = this.FindDescendantOfType(); - if (textDiff == null) - return; + if (UseChangeBlocks) + { + if (DataContext is ViewModels.DiffContext diffCtx) + diffCtx.PrevChange(); + } + else + { + var textDiff = this.FindDescendantOfType(); + if (textDiff == null) + return; - textDiff.GotoPrevChange(); - if (textDiff is SingleSideTextDiffPresenter presenter) - presenter.ForceSyncScrollOffset(); + textDiff.GotoPrevChange(); + if (textDiff is SingleSideTextDiffPresenter presenter) + presenter.ForceSyncScrollOffset(); - e.Handled = true; + e.Handled = true; + } } private void OnGotoNextChange(object _, RoutedEventArgs e) { - var textDiff = this.FindDescendantOfType(); - if (textDiff == null) - return; + if (UseChangeBlocks) + { + if (DataContext is ViewModels.DiffContext diffCtx) + diffCtx.NextChange(); + } + else + { + var textDiff = this.FindDescendantOfType(); + if (textDiff == null) + return; - textDiff.GotoNextChange(); - if (textDiff is SingleSideTextDiffPresenter presenter) - presenter.ForceSyncScrollOffset(); + textDiff.GotoNextChange(); + if (textDiff is SingleSideTextDiffPresenter presenter) + presenter.ForceSyncScrollOffset(); - e.Handled = true; + e.Handled = true; + } } } }