diff --git a/src/Resources/Themes.axaml b/src/Resources/Themes.axaml index dedea275..03bf66a9 100644 --- a/src/Resources/Themes.axaml +++ b/src/Resources/Themes.axaml @@ -11,7 +11,9 @@ #FFB0CEE8 #FF1F1F1F #FF836C2E - #FFFFFFFF + #FFFFFFFF + #400078D7 + #40FF8C00 #FFCFCFCF #FF898989 #FFCFCFCF @@ -24,11 +26,6 @@ #80FF9797 #A7E1A7 #F19B9D - #400078D7 - #40FF8C00 - #FF0078D7 - #FFFF8C00 - #40FFFF00 #0000EE #FFE4E4E4 Black @@ -44,7 +41,9 @@ #FF8F8F8F #FFDDDDDD #FFFAFAD2 - #FF252525 + #FF252525 + #400078D7 + #40FF8C00 #FF181818 #FF7C7C7C #FF404040 @@ -57,11 +56,6 @@ #C0633F3E #A0308D3C #A09F4247 - #400078D7 - #40FF8C00 - #FF0078D7 - #FFFF8C00 - #40FFFF00 #4DAAFC #FF383838 #FFF0F0F0 @@ -77,7 +71,9 @@ - + + + @@ -92,11 +88,6 @@ - - - - - diff --git a/src/ViewModels/Conflict.cs b/src/ViewModels/Conflict.cs index 2696b608..06ac6077 100644 --- a/src/ViewModels/Conflict.cs +++ b/src/ViewModels/Conflict.cs @@ -52,14 +52,14 @@ namespace SourceGit.ViewModels if (CanMerge) IsResolved = new Commands.IsConflictResolved(repo.FullPath, change).GetResult(); - var head = new Commands.QuerySingleCommit(repo.FullPath, "HEAD").GetResult(); + _head = new Commands.QuerySingleCommit(repo.FullPath, "HEAD").GetResult(); (Mine, Theirs) = wc.InProgressContext switch { - CherryPickInProgress cherryPick => (head, cherryPick.Head), + CherryPickInProgress cherryPick => (_head, cherryPick.Head), RebaseInProgress rebase => (rebase.Onto, rebase.StoppedAt), - RevertInProgress revert => (head, revert.Head), - MergeInProgress merge => (head, merge.Source), - _ => (head, (object)"Stash or Patch"), + RevertInProgress revert => (_head, revert.Head), + MergeInProgress merge => (_head, merge.Source), + _ => (_head, (object)"Stash or Patch"), }; } @@ -76,7 +76,7 @@ namespace SourceGit.ViewModels public async Task MergeAsync() { if (CanMerge) - await App.ShowDialog(new MergeConflictEditor(_repo, _change.Path)); + await App.ShowDialog(new MergeConflictEditor(_repo, _head, _change.Path)); } public async Task MergeExternalAsync() @@ -87,6 +87,7 @@ namespace SourceGit.ViewModels private Repository _repo = null; private WorkingCopy _wc = null; + private Models.Commit _head = null; private Models.Change _change = null; } } diff --git a/src/ViewModels/MergeConflictEditor.cs b/src/ViewModels/MergeConflictEditor.cs index 33a48331..5c739ae2 100644 --- a/src/ViewModels/MergeConflictEditor.cs +++ b/src/ViewModels/MergeConflictEditor.cs @@ -16,34 +16,44 @@ namespace SourceGit.ViewModels get => _filePath; } + public object Mine + { + get; + } + + public object Theirs + { + get; + } + public string Error { get => _error; private set => SetProperty(ref _error, value); } - public List OursDiffLines + public List OursLines { - get => _oursDiffLines; - private set => SetProperty(ref _oursDiffLines, value); + get => _oursLines; + private set => SetProperty(ref _oursLines, value); } - public List TheirsDiffLines + public List TheirsLines { - get => _theirsDiffLines; - private set => SetProperty(ref _theirsDiffLines, value); + get => _theirsLines; + private set => SetProperty(ref _theirsLines, value); } - public List ResultDiffLines + public List ResultLines { - get => _resultDiffLines; - private set => SetProperty(ref _resultDiffLines, value); + get => _resultLines; + private set => SetProperty(ref _resultLines, value); } - public int DiffMaxLineNumber + public int MaxLineNumber { - get => _diffMaxLineNumber; - private set => SetProperty(ref _diffMaxLineNumber, value); + get => _maxLineNumber; + private set => SetProperty(ref _maxLineNumber, value); } public int UnsolvedCount @@ -69,11 +79,20 @@ namespace SourceGit.ViewModels get => _conflictRegions; } - public MergeConflictEditor(Repository repo, string filePath) + public MergeConflictEditor(Repository repo, Models.Commit head, string filePath) { _repo = repo; _filePath = filePath; + (Mine, Theirs) = repo.InProgressContext switch + { + CherryPickInProgress cherryPick => (head, cherryPick.Head), + RebaseInProgress rebase => (rebase.Onto, rebase.StoppedAt), + RevertInProgress revert => (head, revert.Head), + MergeInProgress merge => (head, merge.Source), + _ => (head, (object)"Stash or Patch"), + }; + var workingCopyPath = Path.Combine(_repo.FullPath, _filePath); var workingCopyContent = string.Empty; if (File.Exists(workingCopyPath)) @@ -291,10 +310,9 @@ namespace SourceGit.ViewModels } } - var maxLineNumber = Math.Max(oursLineNumber, theirsLineNumber); - DiffMaxLineNumber = maxLineNumber; - OursDiffLines = oursLines; - TheirsDiffLines = theirsLines; + MaxLineNumber = Math.Max(oursLineNumber, theirsLineNumber); + OursLines = oursLines; + TheirsLines = theirsLines; } private void RefreshDisplayData() @@ -302,9 +320,9 @@ namespace SourceGit.ViewModels var resultLines = new List(); _lineStates.Clear(); - if (_oursDiffLines == null || _oursDiffLines.Count == 0) + if (_oursLines == null || _oursLines.Count == 0) { - ResultDiffLines = resultLines; + ResultLines = resultLines; return; } @@ -312,7 +330,7 @@ namespace SourceGit.ViewModels int currentLine = 0; int conflictIdx = 0; - while (currentLine < _oursDiffLines.Count) + while (currentLine < _oursLines.Count) { // Check if we're at a conflict region Models.ConflictRegion currentRegion = null; @@ -424,7 +442,7 @@ namespace SourceGit.ViewModels } else { - var oursLine = _oursDiffLines[currentLine]; + var oursLine = _oursLines[currentLine]; resultLines.Add(new(oursLine.Type, oursLine.Content, resultLineNumber)); _lineStates.Add(Models.ConflictLineState.Normal); resultLineNumber++; @@ -433,7 +451,7 @@ namespace SourceGit.ViewModels } SelectedChunk = null; - ResultDiffLines = resultLines; + ResultLines = resultLines; var unsolved = new List(); for (var i = 0; i < _conflictRegions.Count; i++) @@ -450,10 +468,10 @@ namespace SourceGit.ViewModels private readonly string _filePath; private string _originalContent = string.Empty; private int _unsolvedCount = 0; - private int _diffMaxLineNumber = 0; - private List _oursDiffLines = []; - private List _theirsDiffLines = []; - private List _resultDiffLines = []; + private int _maxLineNumber = 0; + private List _oursLines = []; + private List _theirsLines = []; + private List _resultLines = []; private List _conflictRegions = []; private List _lineStates = []; private Vector _scrollOffset = Vector.Zero; diff --git a/src/Views/Conflict.axaml b/src/Views/Conflict.axaml index 99e2be14..6c8d1ca2 100644 --- a/src/Views/Conflict.axaml +++ b/src/Views/Conflict.axaml @@ -36,23 +36,7 @@ Foreground="DarkOrange" TextDecorations="Underline" Cursor="Hand" - PointerPressed="OnPressedSHA" - ToolTip.Tip="{Binding}" - ToolTip.ShowDelay="0"> - - - - - - - - - - - - - - + PointerPressed="OnPressedSHA"/> diff --git a/src/Views/MergeConflictEditor.axaml b/src/Views/MergeConflictEditor.axaml index 864af9c9..8ef06b94 100644 --- a/src/Views/MergeConflictEditor.axaml +++ b/src/Views/MergeConflictEditor.axaml @@ -17,7 +17,7 @@ @@ -36,7 +36,7 @@ - + @@ -70,11 +70,13 @@ - @@ -85,22 +87,49 @@ - - - + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - + - - - - - - @@ -248,8 +298,8 @@ + Margin="0,4,4,4" + BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"> diff --git a/src/Views/MergeConflictEditor.axaml.cs b/src/Views/MergeConflictEditor.axaml.cs index 0865d3c9..4831755e 100644 --- a/src/Views/MergeConflictEditor.axaml.cs +++ b/src/Views/MergeConflictEditor.axaml.cs @@ -347,6 +347,8 @@ namespace SourceGit.Views Models.TextMateHelper.SetThemeByApp(_textMate); else if (change.Property == SelectedChunkProperty) TextArea.TextView.InvalidateVisual(); + else if (change.Property == MaxLineNumberProperty) + TextArea.LeftMargins[0].InvalidateMeasure(); } private void UpdateContent() @@ -562,7 +564,7 @@ namespace SourceGit.Views if (DataContext is not ViewModels.MergeConflictEditor vm) return; - var total = vm.OursDiffLines.Count; + var total = vm.OursLines.Count; var unitHeight = Bounds.Height / (total * 1.0); var conflicts = vm.ConflictRegions; var blockBGs = new SolidColorBrush[] { new SolidColorBrush(Colors.Red, 0.6), new SolidColorBrush(Colors.Green, 0.6) }; @@ -607,7 +609,7 @@ namespace SourceGit.Views if (DataContext is not ViewModels.MergeConflictEditor vm) return; - var total = vm.OursDiffLines.Count; + var total = vm.OursLines.Count; var range = DisplayRange; if (range == null || range.End == 0) return; @@ -684,7 +686,7 @@ namespace SourceGit.Views if (IsLoaded && DataContext is ViewModels.MergeConflictEditor vm && vm.UnsolvedCount > 0) { var view = OursPresenter.TextArea?.TextView; - var lines = vm.OursDiffLines; + var lines = vm.OursLines; var minY = double.MaxValue; var minLineIdx = lines.Count; if (view is { VisualLinesValid: true }) @@ -727,7 +729,7 @@ namespace SourceGit.Views if (IsLoaded && DataContext is ViewModels.MergeConflictEditor vm && vm.UnsolvedCount > 0) { var view = OursPresenter.TextArea?.TextView; - var lines = vm.OursDiffLines; + var lines = vm.OursLines; var maxY = 0.0; var maxLineIdx = 0; if (view is { VisualLinesValid: true }) diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index 777e694d..fc2e8188 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -652,8 +652,8 @@ - - + + @@ -664,8 +664,8 @@ - - + - - + + @@ -694,10 +694,10 @@ - - + + - + @@ -730,14 +730,14 @@ diff --git a/src/Views/WorkingCopy.axaml.cs b/src/Views/WorkingCopy.axaml.cs index deffa520..78f7c51c 100644 --- a/src/Views/WorkingCopy.axaml.cs +++ b/src/Views/WorkingCopy.axaml.cs @@ -343,7 +343,8 @@ namespace SourceGit.Views mergeBuiltin.Icon = App.CreateMenuIcon("Icons.Conflict"); mergeBuiltin.Click += async (_, e) => { - await App.ShowDialog(new ViewModels.MergeConflictEditor(repo, change.Path)); + var head = await new Commands.QuerySingleCommit(repo.FullPath, "HEAD").GetResultAsync(); + await App.ShowDialog(new ViewModels.MergeConflictEditor(repo, head, change.Path)); e.Handled = true; };