From 052b1e4d1b69ec0f31313ee87928b759c68817cd Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Mon, 22 Aug 2022 13:39:02 +0200 Subject: [PATCH] Git - Clear global state if setting is not enabled (#158747) Clear global state if setting is not enabled --- extensions/git/src/postCommitCommands.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/extensions/git/src/postCommitCommands.ts b/extensions/git/src/postCommitCommands.ts index eb669659d6a..1509aa35177 100644 --- a/extensions/git/src/postCommitCommands.ts +++ b/extensions/git/src/postCommitCommands.ts @@ -82,14 +82,19 @@ export class CommitCommandsCenter { private readonly postCommitCommandsProviderRegistry: IPostCommitCommandsProviderRegistry ) { const root = Uri.file(repository.root); - this.disposables.push(workspace.onDidChangeConfiguration(async e => { + + const onRememberPostCommitCommandChange = async () => { + const config = workspace.getConfiguration('git', root); + if (!config.get('rememberPostCommitCommand')) { + await this.globalState.update(repository.root, undefined); + } + }; + this.disposables.push(workspace.onDidChangeConfiguration(e => { if (e.affectsConfiguration('git.rememberPostCommitCommand', root)) { - const config = workspace.getConfiguration('git', root); - if (!config.get('rememberPostCommitCommand')) { - await this.globalState.update(repository.root, undefined); - } + onRememberPostCommitCommandChange(); } })); + onRememberPostCommitCommandChange(); this.disposables.push(postCommitCommandsProviderRegistry.onDidChangePostCommitCommandsProviders(() => this._onDidChange.fire())); }