From 01d96eefee021cc05bf0efa753848cbf6a37bd85 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 15 Dec 2021 00:55:20 -0500 Subject: [PATCH] Fixes issue with status bar hover Removes bad test code & improves cancellation --- src/hovers/hovers.ts | 9 +++++++-- src/statusbar/statusBarController.ts | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/hovers/hovers.ts b/src/hovers/hovers.ts index ca608bc..6fc0902 100644 --- a/src/hovers/hovers.ts +++ b/src/hovers/hovers.ts @@ -1,5 +1,5 @@ 'use strict'; -import { MarkdownString } from 'vscode'; +import { CancellationToken, MarkdownString } from 'vscode'; import { DiffWithCommand, ShowQuickCommitCommand } from '../commands'; import { GlyphChars } from '../constants'; import { Container } from '../container'; @@ -189,6 +189,7 @@ export namespace Hovers { dateFormat: string | null, options?: { autolinks?: boolean; + cancellationToken?: CancellationToken; pullRequests?: { enabled: boolean; pr?: PullRequest | Promises.CancellationError>; @@ -205,6 +206,8 @@ export namespace Hovers { const remotes = await Container.instance.git.getRemotes(commit.repoPath, { sort: true }); + if (options?.cancellationToken?.isCancellationRequested) return new MarkdownString(); + const [previousLineDiffUris, autolinkedIssuesOrPullRequests, pr, presence] = await Promise.all([ commit.isUncommitted ? commit.getPreviousLineDiffUris(uri, editorLine, uri.sha) : undefined, getAutoLinkedIssuesOrPullRequests(commit.message, remotes), @@ -224,6 +227,8 @@ export namespace Hovers { Container.instance.vsls.maybeGetPresence(commit.email), ]); + if (options?.cancellationToken?.isCancellationRequested) return new MarkdownString(); + const details = await CommitFormatter.fromTemplateAsync(format, commit, { autolinkedIssuesOrPullRequests: autolinkedIssuesOrPullRequests, dateFormat: dateFormat, @@ -261,7 +266,7 @@ export namespace Hovers { } async function getAutoLinkedIssuesOrPullRequests(message: string, remotes: GitRemote[]) { - const cc = Logger.getNewCorrelationContext('Hovers.getAutoLinkedIssues'); + const cc = Logger.getNewCorrelationContext('Hovers.getAutoLinkedIssuesOrPullRequests'); Logger.debug(cc, `${GlyphChars.Dash} message=`); const start = hrtime(); diff --git a/src/statusbar/statusBarController.ts b/src/statusbar/statusBarController.ts index 519b880..47e9c44 100644 --- a/src/statusbar/statusBarController.ts +++ b/src/statusbar/statusBarController.ts @@ -18,7 +18,7 @@ import { Container } from '../container'; import { CommitFormatter, GitBlameCommit, PullRequest } from '../git/git'; import { Hovers } from '../hovers/hovers'; import { LogCorrelationContext, Logger } from '../logger'; -import { debug, Functions, Promises } from '../system'; +import { debug, Promises } from '../system'; import { LinesChangeEvent } from '../trackers/gitLineTracker'; export class StatusBarController implements Disposable { @@ -359,7 +359,6 @@ export class StatusBarController implements Disposable { ) { if (cancellationToken.isCancellationRequested) return; - void (await Functions.wait(10000)); const tooltip = await Hovers.detailsMessage( commit, commit.toGitUri(), @@ -368,6 +367,7 @@ export class StatusBarController implements Disposable { this.container.config.defaultDateFormat, { autolinks: true, + cancellationToken: cancellationToken, getBranchAndTagTips: getBranchAndTagTips, pullRequests: pullRequests, },