Skip to content

Commit 052b1e4

Browse files
authored
Git - Clear global state if setting is not enabled (microsoft#158747)
Clear global state if setting is not enabled
1 parent c2d963e commit 052b1e4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

extensions/git/src/postCommitCommands.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,19 @@ export class CommitCommandsCenter {
8282
private readonly postCommitCommandsProviderRegistry: IPostCommitCommandsProviderRegistry
8383
) {
8484
const root = Uri.file(repository.root);
85-
this.disposables.push(workspace.onDidChangeConfiguration(async e => {
85+
86+
const onRememberPostCommitCommandChange = async () => {
87+
const config = workspace.getConfiguration('git', root);
88+
if (!config.get<boolean>('rememberPostCommitCommand')) {
89+
await this.globalState.update(repository.root, undefined);
90+
}
91+
};
92+
this.disposables.push(workspace.onDidChangeConfiguration(e => {
8693
if (e.affectsConfiguration('git.rememberPostCommitCommand', root)) {
87-
const config = workspace.getConfiguration('git', root);
88-
if (!config.get<boolean>('rememberPostCommitCommand')) {
89-
await this.globalState.update(repository.root, undefined);
90-
}
94+
onRememberPostCommitCommandChange();
9195
}
9296
}));
97+
onRememberPostCommitCommandChange();
9398

9499
this.disposables.push(postCommitCommandsProviderRegistry.onDidChangePostCommitCommandsProviders(() => this._onDidChange.fire()));
95100
}

0 commit comments

Comments
 (0)