mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
feature<TextDiffView>: do NOT reset scroll offset after recompute diff with same change
This commit is contained in:
parent
096fd6cb22
commit
2b97d7c599
5 changed files with 38 additions and 12 deletions
|
@ -1,4 +1,5 @@
|
|||
using Avalonia.Threading;
|
||||
using Avalonia;
|
||||
using Avalonia.Threading;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -49,6 +50,11 @@ namespace SourceGit.ViewModels {
|
|||
private set => SetProperty(ref _content, value);
|
||||
}
|
||||
|
||||
public Vector SyncScrollOffset {
|
||||
get => _syncScrollOffset;
|
||||
set => SetProperty(ref _syncScrollOffset, value);
|
||||
}
|
||||
|
||||
public DiffContext(string repo, Models.DiffOption option) {
|
||||
_repo = repo;
|
||||
_option = option;
|
||||
|
@ -113,5 +119,6 @@ namespace SourceGit.ViewModels {
|
|||
private bool _isNoChange = false;
|
||||
private bool _isTextDiff = false;
|
||||
private object _content = null;
|
||||
private Vector _syncScrollOffset = Vector.Zero;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,6 @@ using System.Collections.Generic;
|
|||
|
||||
namespace SourceGit.ViewModels {
|
||||
public class TwoSideTextDiff : ObservableObject {
|
||||
public Vector SyncScrollOffset {
|
||||
get => _syncScrollOffset;
|
||||
set => SetProperty(ref _syncScrollOffset, value);
|
||||
}
|
||||
|
||||
public string File { get; set; } = string.Empty;
|
||||
public List<Models.TextDiffLine> Old { get; set; } = new List<Models.TextDiffLine>();
|
||||
public List<Models.TextDiffLine> New { get; set; } = new List<Models.TextDiffLine>();
|
||||
|
@ -46,7 +41,5 @@ namespace SourceGit.ViewModels {
|
|||
for (int i = 0; i < diff; i++) New.Add(new Models.TextDiffLine());
|
||||
}
|
||||
}
|
||||
|
||||
private Vector _syncScrollOffset;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue