Skip to content

Commit

Permalink
fixup! review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gerhardol committed Jan 19, 2022
1 parent 3e5a362 commit 0173b53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 7 additions & 3 deletions GitUI/CommandsDialogs/RevisionDiffControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ private void ResetSelectedItemsTo(bool actsAsChild)
RequestRefresh();
}

private Task ShowSelectedFileBlameAsync()
private async Task ShowSelectedFileBlameAsync()
{
int? line = DiffText.Visible ? DiffText.CurrentFileLine : null;

Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions GitUI/UserControls/BlameControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@ public void HideCommitInfo()
CommitInfo.CommandClicked -= commitInfo_CommandClicked;
}

public Task LoadBlameAsync(GitRevision revision, IReadOnlyList<ObjectId>? 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<ObjectId>? 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;

Expand All @@ -124,7 +124,7 @@ public Task LoadBlameAsync(GitRevision revision, IReadOnlyList<ObjectId>? 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));
}

Expand Down

0 comments on commit 0173b53

Please sign in to comment.