From 2edf01db3bc7e9fb87a22713852e1d3cbac49191 Mon Sep 17 00:00:00 2001 From: goran-w Date: Fri, 15 Nov 2024 13:43:05 +0100 Subject: [PATCH] Improve navigation behavior Prev/next at start/end of range now (re-)scrolls to first/last change-block (I.e when unset, or already at first/last change-block, or at the only one.) Current change-block is now unset in RefreshContent(). --- src/ViewModels/DiffContext.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index a87e0bd3..51418baf 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -78,9 +78,15 @@ namespace SourceGit.ViewModels if (_content is Models.TextDiff textDiff) { if (textDiff.CurrentChangeBlockIdx > 0) + { textDiff.CurrentChangeBlockIdx--; - else if (textDiff.CurrentChangeBlockIdx == -1 && textDiff.ChangeBlocks.Count > 0) - textDiff.CurrentChangeBlockIdx = 0; // Jump to first change block + } + else if (textDiff.ChangeBlocks.Count > 0) + { + // Force property value change and (re-)jump to first change block + textDiff.CurrentChangeBlockIdx = -1; + textDiff.CurrentChangeBlockIdx = 0; + } } } @@ -89,7 +95,15 @@ namespace SourceGit.ViewModels if (_content is Models.TextDiff textDiff) { if (textDiff.CurrentChangeBlockIdx < textDiff.ChangeBlocks.Count - 1) + { textDiff.CurrentChangeBlockIdx++; + } + else if (textDiff.ChangeBlocks.Count > 0) + { + // Force property value change and (re-)jump to last change block + textDiff.CurrentChangeBlockIdx = -1; + textDiff.CurrentChangeBlockIdx = textDiff.ChangeBlocks.Count - 1; + } } }