feature<TextDiffView>: do NOT reset scroll offset after recompute diff with same change

This commit is contained in:
leo 2024-02-29 11:29:54 +08:00
parent 096fd6cb22
commit 2b97d7c599
5 changed files with 38 additions and 12 deletions

View file

@ -1,4 +1,5 @@
using Avalonia.Controls;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
@ -194,6 +195,9 @@ namespace SourceGit.ViewModels {
// Restore last selection states.
if (viewChange != null) {
var scrollOffset = Vector.Zero;
if (_detailContext is DiffContext old) scrollOffset = old.SyncScrollOffset;
if (lastSelectedIsUnstaged) {
SelectedUnstagedChange = viewChange;
SelectedUnstagedTreeNode = FileTreeNode.SelectByPath(_unstagedTree, viewFile);
@ -201,6 +205,8 @@ namespace SourceGit.ViewModels {
SelectedStagedChange = viewChange;
SelectedStagedTreeNode = FileTreeNode.SelectByPath(_stagedTree, viewFile);
}
if (_detailContext is DiffContext cur) cur.SyncScrollOffset = scrollOffset;
} else {
SelectedUnstagedChange = null;
SelectedUnstagedTreeNode = null;