From 8de37720faff606935be2fed5a278d18fe8a6237 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 10 Nov 2024 13:19:25 +0800 Subject: [PATCH] code_style: remove Rider warnings Signed-off-by: leo --- src/ViewModels/CommitDetail.cs | 2 +- src/ViewModels/Histories.cs | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 3f41eb99..cf677c34 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -196,7 +196,7 @@ namespace SourceGit.ViewModels var stream = Commands.QueryFileContent.Run(_repo.FullPath, _commit.SHA, file.Path); var fileSize = stream.Length; var bitmap = fileSize > 0 ? new Bitmap(stream) : null; - var imageType = Path.GetExtension(file.Path).TrimStart('.').ToUpper(CultureInfo.CurrentCulture); + var imageType = ext!.Substring(1).ToUpper(CultureInfo.CurrentCulture); var image = new Models.RevisionImageFile() { Image = bitmap, FileSize = fileSize, ImageType = imageType }; Dispatcher.UIThread.Invoke(() => ViewRevisionFileContent = image); } diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index 47736a06..55b04713 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -153,12 +153,9 @@ namespace SourceGit.ViewModels } else if (commits.Count == 1) { - var commit = commits[0] as Models.Commit; - + var commit = (commits[0] as Models.Commit)!; if (_repo.SearchResultSelectedCommit == null || _repo.SearchResultSelectedCommit.SHA != commit.SHA) - { _repo.SearchResultSelectedCommit = _repo.SearchedCommits.Find(x => x.SHA == commit.SHA); - } AutoSelectedCommit = commit; NavigationId = _navigationId + 1; @@ -224,7 +221,7 @@ namespace SourceGit.ViewModels public ContextMenu MakeContextMenu(ListBox list) { var current = _repo.CurrentBranch; - if (current == null) + if (current == null || list.SelectedItems == null) return null; if (list.SelectedItems.Count > 1)