diff --git a/src/common/executeCommands.ts b/src/common/executeCommands.ts index e35bb7ae39..0714a262b0 100644 --- a/src/common/executeCommands.ts +++ b/src/common/executeCommands.ts @@ -18,6 +18,7 @@ export namespace contexts { export const RESOLVING_CONFLICTS = 'github:resolvingConflicts'; export const PULL_REQUEST_DESCRIPTION_VISIBLE = 'github:pullRequestDescriptionVisible'; export const ACTIVE_COMMENT_HAS_SUGGESTION = 'github:activeCommentHasSuggestion'; + export const CREATING = 'pr:creating'; } export namespace commands { diff --git a/src/github/createPRViewProvider.ts b/src/github/createPRViewProvider.ts index 07c84e4b08..f5a4574184 100644 --- a/src/github/createPRViewProvider.ts +++ b/src/github/createPRViewProvider.ts @@ -1174,7 +1174,7 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv CreatePullRequestViewProvider.withProgress(() => { return vscode.window.withProgress({ location: vscode.ProgressLocation.Notification }, async progress => { - commands.setContext('pr:creating', true); + commands.setContext(contexts.CREATING, true); let totalIncrement = 0; progress.report({ message: vscode.l10n.t('Checking for upstream branch'), increment: totalIncrement }); let createdPR: PullRequestModel | undefined = undefined; @@ -1260,7 +1260,7 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv vscode.window.showErrorMessage(vscode.l10n.t('There was an error creating the pull request: {0}', (e as Error).message)); } } finally { - commands.setContext('pr:creating', false); + commands.setContext(contexts.CREATING, false); let completeMessage: string; if (createdPR) { diff --git a/src/github/revertPRViewProvider.ts b/src/github/revertPRViewProvider.ts index 2e02f8915f..b9819c1d19 100644 --- a/src/github/revertPRViewProvider.ts +++ b/src/github/revertPRViewProvider.ts @@ -6,7 +6,7 @@ import * as vscode from 'vscode'; import { CreateParamsNew, CreatePullRequestNew } from '../../common/views'; import { openDescription } from '../commands'; -import { commands } from '../common/executeCommands'; +import { commands, contexts } from '../common/executeCommands'; import { ITelemetry } from '../common/telemetry'; import { IRequestMessage } from '../common/webview'; import { BaseCreatePullRequestViewProvider, BasePullRequestDataModel } from './createPRViewProvider'; @@ -78,7 +78,7 @@ export class RevertPullRequestViewProvider extends BaseCreatePullRequestViewProv protected async create(message: IRequestMessage): Promise { let revertPr: PullRequestModel | undefined; RevertPullRequestViewProvider.withProgress(async () => { - commands.setContext('pr:creating', true); + commands.setContext(contexts.CREATING, true); try { revertPr = await this._folderRepositoryManager.revert(this.pullRequest, message.args.title, message.args.body, message.args.draft); if (revertPr) { @@ -102,7 +102,7 @@ export class RevertPullRequestViewProvider extends BaseCreatePullRequestViewProv vscode.window.showErrorMessage(vscode.l10n.t('There was an error creating the pull request: {0}', (e as Error).message)); } } finally { - commands.setContext('pr:creating', false); + commands.setContext(contexts.CREATING, false); if (revertPr) { this._onDone.fire(revertPr); } else { diff --git a/src/view/createPullRequestHelper.ts b/src/view/createPullRequestHelper.ts index a1abab4c0e..c7cffb524d 100644 --- a/src/view/createPullRequestHelper.ts +++ b/src/view/createPullRequestHelper.ts @@ -5,6 +5,7 @@ import * as vscode from 'vscode'; import { Repository } from '../api/api'; +import { commands } from '../common/executeCommands'; import { ITelemetry } from '../common/telemetry'; import { dispose } from '../common/utils'; import { BaseCreatePullRequestViewProvider, BasePullRequestDataModel, CreatePullRequestViewProvider } from '../github/createPRViewProvider'; @@ -25,14 +26,13 @@ export class CreatePullRequestHelper implements vscode.Disposable { private async setActiveContext(value: boolean) { if (this._activeContext) { - await vscode.commands.executeCommand('setContext', this._activeContext, value); + await commands.setContext(this._activeContext, value); } } private registerListeners(repository: Repository, usingCurrentBranchAsCompare: boolean) { this._disposables.push( this._createPRViewProvider!.onDone(async createdPR => { - this.setActiveContext(false); await CreatePullRequestViewProvider.withProgress(async () => { return this._postCreateCallback?.(createdPR); }); diff --git a/src/view/reviewManager.ts b/src/view/reviewManager.ts index 9a028b260b..4271d6b08a 100644 --- a/src/view/reviewManager.ts +++ b/src/view/reviewManager.ts @@ -1294,7 +1294,7 @@ export class ReviewManager { if (postCreate === 'checkoutDefaultBranch') { await this._folderRepoManager.checkoutDefaultBranch(defaultBranch); } if (postCreate === 'checkoutDefaultBranchAndShow') { - await vscode.commands.executeCommand('pr:github.focus'); + await commands.executeCommand('pr:github.focus'); await this._folderRepoManager.checkoutDefaultBranch(defaultBranch); await this._pullRequestsTree.expandPullRequest(createdPR); } else if (postCreate === 'checkoutDefaultBranchAndCopy') {