Skip to content

Commit 58e7c7b

Browse files
authored
check kernel detection tasks in next frame. (microsoft#167025)
* check kernel detection tasks in next frame. * Update comments
1 parent 1cbc773 commit 58e7c7b

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,30 @@ class NotebookKernelDetection extends Disposable implements IWorkbenchContributi
6868
}
6969
}));
7070

71-
this._register(this._extensionService.onDidChangeExtensionsStatus(() => {
72-
for (const [notebookType, task] of this._detectionMap) {
73-
if (this._extensionService.activationEventIsDone(`onNotebook:${notebookType}`)) {
74-
task.dispose();
75-
}
71+
let timer: any = null;
72+
73+
this._localDisposableStore.add(this._extensionService.onDidChangeExtensionsStatus(() => {
74+
if (timer) {
75+
clearTimeout(timer);
7676
}
77+
78+
// activation state might not be updated yet, postpone to next frame
79+
timer = setTimeout(() => {
80+
for (const [notebookType, task] of this._detectionMap) {
81+
if (this._extensionService.activationEventIsDone(`onNotebook:${notebookType}`)) {
82+
task.dispose();
83+
}
84+
}
85+
});
7786
}));
87+
88+
this._localDisposableStore.add({
89+
dispose: () => {
90+
if (timer) {
91+
clearTimeout(timer);
92+
}
93+
}
94+
});
7895
}
7996
}
8097
}

0 commit comments

Comments
 (0)