From 962055dd2ac82011e68fb53de0c138807ca82ff3 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 8 Dec 2024 21:51:33 +0800 Subject: [PATCH] code_style: run `dotnet format` Signed-off-by: leo --- src/ViewModels/BlockNavigation.cs | 24 +++++++++++++----------- src/ViewModels/CommitDetail.cs | 7 ++++--- src/Views/RepositoryToolbar.axaml.cs | 2 -- src/Views/TextDiffView.axaml.cs | 16 ++++++++-------- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/ViewModels/BlockNavigation.cs b/src/ViewModels/BlockNavigation.cs index b4466f98..709338f8 100644 --- a/src/ViewModels/BlockNavigation.cs +++ b/src/ViewModels/BlockNavigation.cs @@ -40,19 +40,19 @@ namespace SourceGit.ViewModels { if (Blocks.Count == 0) return "-/-"; - + if (_current >= 0 && _current < Blocks.Count) - return $"{_current+1}/{Blocks.Count}"; + return $"{_current + 1}/{Blocks.Count}"; return $"-/{Blocks.Count}"; } } - + public BlockNavigation(object context) { Blocks.Clear(); Current = -1; - + var lines = new List(); if (context is Models.TextDiff combined) lines = combined.Lines; @@ -61,12 +61,12 @@ namespace SourceGit.ViewModels if (lines.Count == 0) return; - + var lineIdx = 0; var blockStartIdx = 0; var isNewBlock = true; var blocks = new List(); - + foreach (var line in lines) { lineIdx++; @@ -89,7 +89,7 @@ namespace SourceGit.ViewModels } } } - + if (!isNewBlock) blocks.Add(new Block(blockStartIdx, lines.Count - 1)); @@ -103,16 +103,18 @@ namespace SourceGit.ViewModels public Block GotoNext() { - if (Blocks.Count == 0) return null; - + if (Blocks.Count == 0) + return null; + Current = (_current + 1) % Blocks.Count; return Blocks[_current]; } public Block GotoPrev() { - if (Blocks.Count == 0) return null; - + if (Blocks.Count == 0) + return null; + Current = _current == -1 ? Blocks.Count - 1 : (_current - 1 + Blocks.Count) % Blocks.Count; return Blocks[_current]; } diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 29de3946..bf9f57c9 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -121,7 +121,7 @@ namespace SourceGit.ViewModels if (SetProperty(ref _revisionFileSearchFilter, value)) { RevisionFileSearchSuggestion.Clear(); - + if (!string.IsNullOrEmpty(value)) { if (_revisionFiles.Count == 0) @@ -132,7 +132,8 @@ namespace SourceGit.ViewModels { var files = new Commands.QueryRevisionFileNames(_repo.FullPath, sha).Result(); - Dispatcher.UIThread.Invoke(() => { + Dispatcher.UIThread.Invoke(() => + { if (sha == Commit.SHA) { _revisionFiles.Clear(); @@ -795,7 +796,7 @@ namespace SourceGit.ViewModels var suggestion = new List(); foreach (var file in _revisionFiles) { - if (file.Contains(_revisionFileSearchFilter, StringComparison.OrdinalIgnoreCase) && + if (file.Contains(_revisionFileSearchFilter, StringComparison.OrdinalIgnoreCase) && file.Length != _revisionFileSearchFilter.Length) suggestion.Add(file); diff --git a/src/Views/RepositoryToolbar.axaml.cs b/src/Views/RepositoryToolbar.axaml.cs index 5279382b..aa78c4d3 100644 --- a/src/Views/RepositoryToolbar.axaml.cs +++ b/src/Views/RepositoryToolbar.axaml.cs @@ -1,5 +1,3 @@ -using System; - using Avalonia.Controls; using Avalonia.Input; using Avalonia.Interactivity; diff --git a/src/Views/TextDiffView.axaml.cs b/src/Views/TextDiffView.axaml.cs index 008d3bd9..a4c2bd0a 100644 --- a/src/Views/TextDiffView.axaml.cs +++ b/src/Views/TextDiffView.axaml.cs @@ -557,7 +557,7 @@ namespace SourceGit.Views return; } - + var firstLineIdx = DisplayRange.StartIdx; if (firstLineIdx <= 1) return; @@ -600,7 +600,7 @@ namespace SourceGit.Views } public void GotoNextChange() - { + { var blockNavigation = BlockNavigation; if (blockNavigation != null) { @@ -613,7 +613,7 @@ namespace SourceGit.Views return; } - + var lines = GetLines(); var lastLineIdx = DisplayRange.EndIdx; if (lastLineIdx >= lines.Count - 1) @@ -724,7 +724,7 @@ namespace SourceGit.Views oldValue.PropertyChanged -= OnBlockNavigationPropertyChanged; if (newValue != null) newValue.PropertyChanged += OnBlockNavigationPropertyChanged; - + InvalidateVisual(); } } @@ -1557,7 +1557,7 @@ namespace SourceGit.Views get => GetValue(BlockNavigationProperty); set => SetValue(BlockNavigationProperty, value); } - + public static readonly StyledProperty BlockNavigationIndicatorProperty = AvaloniaProperty.Register(nameof(BlockNavigationIndicator)); @@ -1599,7 +1599,7 @@ namespace SourceGit.Views { InitializeComponent(); } - + public void GotoPrevChange() { var presenter = this.FindDescendantOfType(); @@ -1609,7 +1609,7 @@ namespace SourceGit.Views presenter.GotoPrevChange(); if (presenter is SingleSideTextDiffPresenter singleSide) singleSide.ForceSyncScrollOffset(); - + BlockNavigationIndicator = BlockNavigation?.Indicator ?? string.Empty; } @@ -1622,7 +1622,7 @@ namespace SourceGit.Views presenter.GotoNextChange(); if (presenter is SingleSideTextDiffPresenter singleSide) singleSide.ForceSyncScrollOffset(); - + BlockNavigationIndicator = BlockNavigation?.Indicator ?? string.Empty; }