From 0173b53ed005f5f8b47768e9840bcff8a6ef5b98 Mon Sep 17 00:00:00 2001 From: Gerhard Olsson Date: Wed, 19 Jan 2022 23:58:03 +0100 Subject: [PATCH] fixup! review comments --- GitUI/CommandsDialogs/RevisionDiffControl.cs | 10 +++++++--- GitUI/UserControls/BlameControl.cs | 10 +++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/GitUI/CommandsDialogs/RevisionDiffControl.cs b/GitUI/CommandsDialogs/RevisionDiffControl.cs index 19cff19fa58..44d3403683b 100644 --- a/GitUI/CommandsDialogs/RevisionDiffControl.cs +++ b/GitUI/CommandsDialogs/RevisionDiffControl.cs @@ -476,7 +476,7 @@ private void ResetSelectedItemsTo(bool actsAsChild) RequestRefresh(); } - private Task ShowSelectedFileBlameAsync() + private async Task ShowSelectedFileBlameAsync() { int? line = DiffText.Visible ? DiffText.CurrentFileLine : null; @@ -485,7 +485,8 @@ private Task ShowSelectedFileBlameAsync() GitRevision rev = DiffFiles.SelectedItem.SecondRevision.IsArtificial ? _revisionGrid.GetActualRevision(_revisionGrid.CurrentCheckout) : DiffFiles.SelectedItem.SecondRevision; - return BlameControl.LoadBlameAsync(rev, children: null, DiffFiles.SelectedItem.Item.Name, _revisionGrid, controlToMask: null, DiffText.Encoding, line, cancellationToken: _viewChangesSequence.Next()); + await BlameControl.LoadBlameAsync(rev, children: null, DiffFiles.SelectedItem.Item.Name, _revisionGrid, + controlToMask: null, DiffText.Encoding, line, cancellationToken: _viewChangesSequence.Next()); } private async Task ShowSelectedFileDiffAsync() @@ -638,7 +639,10 @@ private void blameToolStripMenuItem_Click(object sender, EventArgs e) } blameToolStripMenuItem.Checked = !blameToolStripMenuItem.Checked; - ShowSelectedFileBlameAsync(); + ThreadHelper.JoinableTaskFactory.RunAsync(async () => + { + await ShowSelectedFileBlameAsync(); + }).FileAndForget(); } private void StageFileToolStripMenuItemClick(object sender, EventArgs e) diff --git a/GitUI/UserControls/BlameControl.cs b/GitUI/UserControls/BlameControl.cs index 0ec68212114..f7c5fea06b6 100644 --- a/GitUI/UserControls/BlameControl.cs +++ b/GitUI/UserControls/BlameControl.cs @@ -97,21 +97,21 @@ public void HideCommitInfo() CommitInfo.CommandClicked -= commitInfo_CommandClicked; } - public Task LoadBlameAsync(GitRevision revision, IReadOnlyList? children, string? fileName, RevisionGridControl? revGrid, Control? controlToMask, Encoding encoding, int? initialLine = null, bool force = false, CancellationToken cancellationToken = default) + public async Task LoadBlameAsync(GitRevision revision, IReadOnlyList? children, string? fileName, RevisionGridControl? revGrid, Control? controlToMask, Encoding encoding, int? initialLine = null, bool force = false, CancellationToken cancellationToken = default) { var objectId = revision.ObjectId; // refresh only when something changed if (!force && objectId == _blameId && fileName == _fileName && revGrid == _revGrid && encoding == _encoding) { - return Task.CompletedTask; + return; } controlToMask?.Mask(); - var scrollPos = BlameFile.VScrollPosition; + int scrollPos = BlameFile.VScrollPosition; - var line = _clickedBlameLine is not null && _clickedBlameLine.Commit.ObjectId == objectId + int line = _clickedBlameLine is not null && _clickedBlameLine.Commit.ObjectId == objectId ? _clickedBlameLine.OriginLineNumber : initialLine ?? 0; @@ -124,7 +124,7 @@ public Task LoadBlameAsync(GitRevision revision, IReadOnlyList? childr BlameAuthor.Clear(); BlameFile.Clear(); - return _blameLoader.LoadAsync(cancellationToken => _blame = Module.Blame(fileName, objectId.ToString(), encoding, cancellationToken: cancellationToken), + await _blameLoader.LoadAsync(cancellationToken => _blame = Module.Blame(fileName, objectId.ToString(), encoding, cancellationToken: cancellationToken), () => ProcessBlame(fileName, revision, children, controlToMask, line, scrollPos, cancellationToken)); }