From 9e6e1312fb3cc8ce6dc398cb4e2ad0f43f441fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Thu, 8 Sep 2022 00:54:35 -0700 Subject: [PATCH] avoid calling setContext when not necessary (#160297) * avoid calling setContext when not necessary * Update extensions/git/src/repository.ts --- extensions/git/src/repository.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index bef5b65a46b..dd2eb143e12 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -833,8 +833,12 @@ export class Repository implements Disposable { this.inputBox.value = rebaseCommit.message; } + const shouldUpdateContext = !!this._rebaseCommit !== !!rebaseCommit; this._rebaseCommit = rebaseCommit; - commands.executeCommand('setContext', 'gitRebaseInProgress', !!this._rebaseCommit); + + if (shouldUpdateContext) { + commands.executeCommand('setContext', 'gitRebaseInProgress', !!this._rebaseCommit); + } } get rebaseCommit(): Commit | undefined { @@ -844,6 +848,10 @@ export class Repository implements Disposable { private _mergeInProgress: boolean = false; set mergeInProgress(value: boolean) { + if (this._mergeInProgress === value) { + return; + } + this._mergeInProgress = value; commands.executeCommand('setContext', 'gitMergeInProgress', value); }