From 5301645f8bab7049710b7a9eaf10e2d62ad4fb7c Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Sun, 17 Nov 2024 03:14:56 +0000 Subject: [PATCH 1/4] fix: in commit view get file histories by commit (#708) When file histories are accessed from the commit details view, run git log for the inspected commit. Previously the log was ran against current branch regardless whether the inspected commit belongs to that branch. --- src/ViewModels/CommitDetail.cs | 4 ++-- src/ViewModels/FileHistories.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index ef060f04..7ef8ce85 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -293,7 +293,7 @@ namespace SourceGit.ViewModels history.Icon = App.CreateMenuIcon("Icons.Histories"); history.Click += (_, ev) => { - var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, change.Path) }; + var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, change.Path, _commit.SHA) }; window.Show(); ev.Handled = true; }; @@ -434,7 +434,7 @@ namespace SourceGit.ViewModels history.Icon = App.CreateMenuIcon("Icons.Histories"); history.Click += (_, ev) => { - var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, file.Path) }; + var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, file.Path, _commit.SHA) }; window.Show(); ev.Handled = true; }; diff --git a/src/ViewModels/FileHistories.cs b/src/ViewModels/FileHistories.cs index 035cadfd..52ed6b01 100644 --- a/src/ViewModels/FileHistories.cs +++ b/src/ViewModels/FileHistories.cs @@ -57,14 +57,14 @@ namespace SourceGit.ViewModels private set => SetProperty(ref _viewContent, value); } - public FileHistories(Repository repo, string file) + public FileHistories(Repository repo, string file, string commit = null) { _repo = repo; _file = file; Task.Run(() => { - var commits = new Commands.QueryCommits(_repo.FullPath, $"-n 10000 -- \"{file}\"", false).Result(); + var commits = new Commands.QueryCommits(_repo.FullPath, $"-n 10000 {commit} -- \"{file}\"", false).Result(); Dispatcher.UIThread.Invoke(() => { IsLoading = false; From 6f256f6f5ba78e276c8184972b5d04dc82d8388d Mon Sep 17 00:00:00 2001 From: Nils van Rijsinge Date: Sun, 17 Nov 2024 04:16:31 +0100 Subject: [PATCH 2/4] Add and improve de_DE keys (#709) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * localization: add missing de_DE keys added for #690 * localization: improve de_DE keys - mostly code review suggestions from #664 - ClearAllCommitsFilter is not an action of deleting (löschen) --- src/Resources/Locales/de_DE.axaml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 68310dee..200d3638 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -58,7 +58,7 @@ Lösche alle ausgewählten {0} Branches Alle Änderungen verwerfen Fast-Forward zu ${0}$ - Fetche ${0}$ nach ${1}$... + Fetche ${0}$ in ${1}$ hinein... Git Flow - Abschließen ${0}$ Merge ${0}$ in ${1}$ hinein... Pull ${0}$ @@ -162,8 +162,8 @@ TICKETSYSTEM Beispiel für Github-Regel hinzufügen Beispiel für Jira-Regel hinzufügen - Beispiel für eine Gitlab Issue Regel einfügen - Beispiel für einen Gitlab Merge Request einfügen + Beispiel für Gitlab Issue Regel einfügen + Beispiel für Gitlab Merge Request einfügen Neue Regel Ticketnummer Regex-Ausdruck: Name: @@ -171,7 +171,7 @@ Verwende bitte $1, $2 um auf Regex-Gruppenwerte zuzugreifen. OPEN AI Bevorzugter Service: - Wenn der 'Bevorzugte Service' aktiviert ist, wird SourceGit nur dieses Repository nutzen. Ansonsten wird, wenn mehrere Services verfügbar sind, eine Kontextmenü zur Auswahl angezeigt. + Der ausgewählte 'Bevorzugte Service' wird nur in diesem Repository gesetzt und verwendet. Wenn keiner gesetzt ist und mehrere Servies verfügbar sind wird ein Kontextmenü zur Auswahl angezeigt. HTTP Proxy HTTP Proxy für dieses Repository Benutzername @@ -265,7 +265,7 @@ Ziel: Ausgewählte Gruppe bearbeiten Ausgewähltes Repository bearbeiten - Führe benutzerte Aktion aus + Führe benutzerdefinierte Aktion aus Name der Aktion: Fast-Forward (ohne Auschecken) Fetch @@ -535,7 +535,7 @@ Änderungen automatisch von Remote fetchen... Aufräumen (GC & Prune) Führt `git gc` auf diesem Repository aus. - Alles löschen + Filter aufheben Repository Einstellungen WEITER Benutzerdefinierte Aktionen @@ -543,6 +543,9 @@ Aktiviere '--reflog' Option Öffne im Datei-Browser Suche Branches/Tags/Submodule + Aufheben + Im Graph ausblenden + Im Graph filtern LOKALE BRANCHES Zum HEAD wechseln Aktiviere '--first-parent' Option @@ -601,7 +604,7 @@ START Stash Inklusive nicht-verfolgter Dateien - Behalte Dateien des Stages + Behalte gestagte Dateien Name: Optional. Name dieses Stashes Nur gestagte Änderungen From b7abf2ee5030bedd125eaeb74364f157f7b1d0a1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 17 Nov 2024 03:16:44 +0000 Subject: [PATCH 3/4] doc: Update translation status and missing keys --- README.md | 2 +- TRANSLATION.md | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 382c514f..d49fb1e4 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ ## Translation Status -[![en_US](https://img.shields.io/badge/en__US-100%25-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-99.57%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-99.14%25-yellow)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-98.42%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-99.14%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-100.00%25-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-100.00%25-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-100.00%25-brightgreen)](TRANSLATION.md) +[![en_US](https://img.shields.io/badge/en__US-100%25-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-100.00%25-brightgreen)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-99.14%25-yellow)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-98.42%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-99.14%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-100.00%25-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-100.00%25-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-100.00%25-brightgreen)](TRANSLATION.md) ## How to Use diff --git a/TRANSLATION.md b/TRANSLATION.md index ccfc4df7..5967d21e 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -1,12 +1,10 @@ -### de_DE.axaml: 99.57% +### de_DE.axaml: 100.00%
Missing Keys -- Text.Repository.FilterCommits.Default -- Text.Repository.FilterCommits.Exclude -- Text.Repository.FilterCommits.Include +
From 3b09ea45f5481ebd36983e1368bb3069bf9f205f Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 17 Nov 2024 21:49:33 +0800 Subject: [PATCH 4/4] feature: add change minimap for text diff view Signed-off-by: leo --- src/Views/CommitRefsPresenter.cs | 5 +- src/Views/TextDiffView.axaml | 53 +++++--- src/Views/TextDiffView.axaml.cs | 224 ++++++++++++++++++++++++------- 3 files changed, 216 insertions(+), 66 deletions(-) diff --git a/src/Views/CommitRefsPresenter.cs b/src/Views/CommitRefsPresenter.cs index fc3233a5..e8a66da0 100644 --- a/src/Views/CommitRefsPresenter.cs +++ b/src/Views/CommitRefsPresenter.cs @@ -38,7 +38,7 @@ namespace SourceGit.Views } public static readonly StyledProperty BackgroundProperty = - AvaloniaProperty.Register(nameof(Background), null); + AvaloniaProperty.Register(nameof(Background), Brushes.Transparent); public IBrush Background { @@ -56,7 +56,7 @@ namespace SourceGit.Views } public static readonly StyledProperty UseGraphColorProperty = - AvaloniaProperty.Register(nameof(UseGraphColor), false); + AvaloniaProperty.Register(nameof(UseGraphColor)); public bool UseGraphColor { @@ -96,7 +96,6 @@ namespace SourceGit.Views var x = 1.0; foreach (var item in _items) { - var iconRect = new RoundedRect(new Rect(x, 0, 16, 16), new CornerRadius(2, 0, 0, 2)); var entireRect = new RoundedRect(new Rect(x, 0, item.Width, 16), new CornerRadius(2)); if (item.IsHead) diff --git a/src/Views/TextDiffView.axaml b/src/Views/TextDiffView.axaml index 57427321..f2a5beaf 100644 --- a/src/Views/TextDiffView.axaml +++ b/src/Views/TextDiffView.axaml @@ -13,27 +13,39 @@ - + + + + + + + - + + + + + diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index bf4ffe60..242f8c4c 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -45,6 +45,18 @@ namespace SourceGit.Views } } + public record TextDiffViewRange + { + public int StartIdx { get; set; } = 0; + public int EndIdx { get; set; } = 0; + + public TextDiffViewRange(int startIdx, int endIdx) + { + StartIdx = startIdx; + EndIdx = endIdx; + } + } + public class ThemedTextDiffPresenter : TextEditor { public class VerticalSeperatorMargin : AbstractMargin @@ -210,7 +222,6 @@ namespace SourceGit.Views if (presenter == null) return new Size(0, 0); - var maxLineNumber = presenter.GetMaxLineNumber(); var typeface = TextView.CreateTypeface(); var test = new FormattedText( $"-", @@ -465,6 +476,15 @@ namespace SourceGit.Views get => GetValue(SelectedChunkProperty); set => SetValue(SelectedChunkProperty, value); } + + public static readonly StyledProperty DisplayRangeProperty = + AvaloniaProperty.Register(nameof(DisplayRange), new TextDiffViewRange(0, 0)); + + public TextDiffViewRange DisplayRange + { + get => GetValue(DisplayRangeProperty); + set => SetValue(DisplayRangeProperty, value); + } protected override Type StyleKeyOverride => typeof(TextEditor); @@ -500,25 +520,11 @@ namespace SourceGit.Views public void GotoPrevChange() { - var view = TextArea.TextView; - var lines = GetLines(); - var firstLineIdx = lines.Count; - foreach (var line in view.VisualLines) - { - if (line.IsDisposed || line.FirstDocumentLine == null || line.FirstDocumentLine.IsDeleted) - continue; - - var index = line.FirstDocumentLine.LineNumber - 1; - if (index >= lines.Count) - continue; - - if (firstLineIdx > index) - firstLineIdx = index; - } - + var firstLineIdx = DisplayRange.StartIdx; if (firstLineIdx <= 1) return; - + + var lines = GetLines(); var firstLineType = lines[firstLineIdx].Type; var prevLineType = lines[firstLineIdx - 1].Type; var isChangeFirstLine = firstLineType != Models.TextDiffLineType.Normal && firstLineType != Models.TextDiffLineType.Indicator; @@ -557,22 +563,8 @@ namespace SourceGit.Views public void GotoNextChange() { - var view = TextArea.TextView; var lines = GetLines(); - var lastLineIdx = -1; - foreach (var line in view.VisualLines) - { - if (line.IsDisposed || line.FirstDocumentLine == null || line.FirstDocumentLine.IsDeleted) - continue; - - var index = line.FirstDocumentLine.LineNumber - 1; - if (index >= lines.Count) - continue; - - if (lastLineIdx < index) - lastLineIdx = index; - } - + var lastLineIdx = DisplayRange.EndIdx; if (lastLineIdx >= lines.Count - 1) return; @@ -624,6 +616,7 @@ namespace SourceGit.Views TextArea.TextView.PointerEntered += OnTextViewPointerChanged; TextArea.TextView.PointerMoved += OnTextViewPointerChanged; TextArea.TextView.PointerWheelChanged += OnTextViewPointerWheelChanged; + TextArea.TextView.VisualLinesChanged += OnTextViewVisualLinesChanged; UpdateTextMate(); } @@ -636,6 +629,7 @@ namespace SourceGit.Views TextArea.TextView.PointerEntered -= OnTextViewPointerChanged; TextArea.TextView.PointerMoved -= OnTextViewPointerChanged; TextArea.TextView.PointerWheelChanged -= OnTextViewPointerWheelChanged; + TextArea.TextView.VisualLinesChanged -= OnTextViewVisualLinesChanged; if (_textMate != null) { @@ -743,6 +737,34 @@ namespace SourceGit.Views } } + private void OnTextViewVisualLinesChanged(object sender, EventArgs e) + { + if (!TextArea.TextView.VisualLinesValid) + { + SetCurrentValue(DisplayRangeProperty, new TextDiffViewRange(0, 0)); + return; + } + + var lines = GetLines(); + var start = int.MaxValue; + var count = 0; + foreach (var line in TextArea.TextView.VisualLines) + { + if (line.IsDisposed || line.FirstDocumentLine == null || line.FirstDocumentLine.IsDeleted) + continue; + + var index = line.FirstDocumentLine.LineNumber - 1; + if (index >= lines.Count) + continue; + + count++; + if (start > index) + start = index; + } + + SetCurrentValue(DisplayRangeProperty, new TextDiffViewRange(start, start + count)); + } + protected void TrySetChunk(TextDiffViewChunk chunk) { var old = SelectedChunk; @@ -1050,12 +1072,8 @@ namespace SourceGit.Views private void OnTextViewScrollGotFocus(object sender, GotFocusEventArgs e) { - if (EnableChunkSelection && sender is ScrollViewer viewer) - { - var area = viewer.FindDescendantOfType