diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index aaa6e125..56c924e5 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -14,6 +14,11 @@ namespace SourceGit.Commands public Diff(string repo, Models.DiffOption opt, int unified) { + _result.TextDiff = new Models.TextDiff() { + Repo = repo, + Option = opt, + }; + WorkingDirectory = repo; Context = repo; Args = $"diff --ignore-cr-at-eol --unified={unified} {opt}"; @@ -214,7 +219,7 @@ namespace SourceGit.Commands } } - private readonly Models.DiffResult _result = new Models.DiffResult() { TextDiff = new Models.TextDiff() }; + private readonly Models.DiffResult _result = new Models.DiffResult(); private readonly List _deleted = new List(); private readonly List _added = new List(); private int _oldLine = 0; diff --git a/src/Models/DiffResult.cs b/src/Models/DiffResult.cs index a625fc7b..1c270470 100644 --- a/src/Models/DiffResult.cs +++ b/src/Models/DiffResult.cs @@ -66,6 +66,9 @@ namespace SourceGit.Models public Vector SyncScrollOffset { get; set; } = Vector.Zero; public int MaxLineNumber = 0; + public string Repo { get; set; } = null; + public DiffOption Option { get; set; } = null; + public void GenerateNewPatchFromSelection(Change change, string fileBlobGuid, TextDiffSelection selection, bool revert, string output) { var isTracked = !string.IsNullOrEmpty(fileBlobGuid); diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index e40f4648..eb5d2122 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -307,6 +307,9 @@ Find next match Find previous match Open search panel + Stage Hunk + Unstage Hunk + Discard Hunk Initialize Repository Path: Invalid repository detected. Run `git init` under this path? diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 15700de7..ee1a187b 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -310,6 +310,9 @@ 定位到下一个匹配搜索的位置 定位到上一个匹配搜索的位置 打开搜索 + 暂存片断 + 移出暂存区 + 丢弃片断 初始化新仓库 路径 : 选择目录不是有效的Git仓库。是否需要在此目录执行`git init`操作? diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 569f6b62..77aa22e7 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -310,6 +310,9 @@ 定位到下一個匹配搜尋的位置 定位到上一個匹配搜尋的位置 開啟搜尋 + 暫存片斷 + 移出暫存區 + 丟棄片斷 初始化新倉庫 路徑 : 選擇目錄不是有效的Git倉庫。是否需要在此目錄執行`git init`操作? diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index a2b435cc..db5382d4 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -12,21 +12,6 @@ namespace SourceGit.ViewModels { public class DiffContext : ObservableObject { - public string RepositoryPath - { - get => _repo; - } - - public Models.Change WorkingCopyChange - { - get => _option.WorkingCopyChange; - } - - public bool IsUnstaged - { - get => _option.IsUnstaged; - } - public string Title { get => _title; diff --git a/src/ViewModels/TwoSideTextDiff.cs b/src/ViewModels/TwoSideTextDiff.cs index a3cab886..59e70a88 100644 --- a/src/ViewModels/TwoSideTextDiff.cs +++ b/src/ViewModels/TwoSideTextDiff.cs @@ -17,10 +17,17 @@ namespace SourceGit.ViewModels set => SetProperty(ref _syncScrollOffset, value); } + public Models.DiffOption Option + { + get; + set; + } + public TwoSideTextDiff(Models.TextDiff diff, TwoSideTextDiff previous = null) { File = diff.File; MaxLineNumber = diff.MaxLineNumber; + Option = diff.Option; foreach (var line in diff.Lines) { diff --git a/src/Views/BranchCompare.axaml b/src/Views/BranchCompare.axaml index 56db1dc8..f8a1964f 100644 --- a/src/Views/BranchCompare.axaml +++ b/src/Views/BranchCompare.axaml @@ -132,8 +132,7 @@ - diff --git a/src/Views/ChangeCollectionView.axaml b/src/Views/ChangeCollectionView.axaml index 1b365ff7..fa6c736e 100644 --- a/src/Views/ChangeCollectionView.axaml +++ b/src/Views/ChangeCollectionView.axaml @@ -56,7 +56,7 @@ IsChecked="{Binding IsExpanded}" IsVisible="{Binding IsFolder}"/> - + @@ -75,7 +75,7 @@ IsWorkingCopyChangeProperty = - AvaloniaProperty.Register(nameof(IsWorkingCopyChange)); + public static readonly StyledProperty IsUnstagedChangeProperty = + AvaloniaProperty.Register(nameof(IsUnstagedChange)); - public bool IsWorkingCopyChange + public bool IsUnstagedChange { - get => GetValue(IsWorkingCopyChangeProperty); - set => SetValue(IsWorkingCopyChangeProperty, value); + get => GetValue(IsUnstagedChangeProperty); + set => SetValue(IsUnstagedChangeProperty, value); } public static readonly StyledProperty SelectionModeProperty = diff --git a/src/Views/ChangeStatusIcon.cs b/src/Views/ChangeStatusIcon.cs index 5821b49c..e54b765e 100644 --- a/src/Views/ChangeStatusIcon.cs +++ b/src/Views/ChangeStatusIcon.cs @@ -57,13 +57,13 @@ namespace SourceGit.Views private static readonly string[] INDICATOR = ["?", "±", "+", "−", "➜", "❏", "U", "★"]; - public static readonly StyledProperty IsWorkingCopyChangeProperty = - AvaloniaProperty.Register(nameof(IsWorkingCopyChange)); + public static readonly StyledProperty IsUnstagedChangeProperty = + AvaloniaProperty.Register(nameof(IsUnstagedChange)); - public bool IsWorkingCopyChange + public bool IsUnstagedChange { - get => GetValue(IsWorkingCopyChangeProperty); - set => SetValue(IsWorkingCopyChangeProperty, value); + get => GetValue(IsUnstagedChangeProperty); + set => SetValue(IsUnstagedChangeProperty, value); } public static readonly StyledProperty ChangeProperty = @@ -77,7 +77,7 @@ namespace SourceGit.Views static ChangeStatusIcon() { - AffectsRender(IsWorkingCopyChangeProperty, ChangeProperty); + AffectsRender(IsUnstagedChangeProperty, ChangeProperty); } public override void Render(DrawingContext context) @@ -89,7 +89,7 @@ namespace SourceGit.Views IBrush background; string indicator; - if (IsWorkingCopyChange) + if (IsUnstagedChange) { if (Change.IsConflit) { diff --git a/src/Views/CommitChanges.axaml b/src/Views/CommitChanges.axaml index 849ea1bd..bc36b023 100644 --- a/src/Views/CommitChanges.axaml +++ b/src/Views/CommitChanges.axaml @@ -45,8 +45,7 @@ - diff --git a/src/Views/RevisionCompare.axaml b/src/Views/RevisionCompare.axaml index 745e80f2..630f9752 100644 --- a/src/Views/RevisionCompare.axaml +++ b/src/Views/RevisionCompare.axaml @@ -103,8 +103,7 @@ - diff --git a/src/Views/StashesPage.axaml b/src/Views/StashesPage.axaml index 73792b7d..b6cc9bc6 100644 --- a/src/Views/StashesPage.axaml +++ b/src/Views/StashesPage.axaml @@ -128,7 +128,7 @@ - + diff --git a/src/Views/TextDiffView.axaml b/src/Views/TextDiffView.axaml index 738924b6..47589a12 100644 --- a/src/Views/TextDiffView.axaml +++ b/src/Views/TextDiffView.axaml @@ -9,29 +9,11 @@ x:Class="SourceGit.Views.TextDiffView" x:Name="ThisControl" Background="{DynamicResource Brush.Contents}"> - - - - - - - - + + + + + HighlightChunk="{Binding #ThisControl.HighlightChunk, Mode=TwoWay}"/> + - + + + - - - - + + + + + + + + + +