Skip to content

Commit

Permalink
Revert "Only one subscriber for kernels for onDidChangeSelectedNotebo…
Browse files Browse the repository at this point in the history
…oks (#204417)" (#207132)

This reverts commit 59ec734.
  • Loading branch information
rebornix authored Mar 8, 2024
1 parent 1c2151a commit 6c19c00
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/vs/workbench/api/browser/mainThreadNotebookKernels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isNonEmptyArray } from 'vs/base/common/arrays';
import { CancellationToken } from 'vs/base/common/cancellation';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Emitter, Event } from 'vs/base/common/event';
import { DisposableMap, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { combinedDisposable, DisposableMap, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { URI, UriComponents } from 'vs/base/common/uri';
import { ILanguageService } from 'vs/editor/common/languages/language';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
Expand Down Expand Up @@ -151,16 +151,6 @@ export class MainThreadNotebookKernels implements MainThreadNotebookKernelsShape
this._proxy.$cellExecutionChanged(e.notebook, e.cellHandle, e.changed?.state);
}
}));

this._disposables.add(this._notebookKernelService.onDidChangeSelectedNotebooks(e => {
for (const [handle, [kernel,]] of this._kernels) {
if (e.oldKernel === kernel.id) {
this._proxy.$acceptNotebookAssociation(handle, e.notebook, false);
} else if (e.newKernel === kernel.id) {
this._proxy.$acceptNotebookAssociation(handle, e.notebook, true);
}
}
}));
}

dispose(): void {
Expand Down Expand Up @@ -272,8 +262,16 @@ export class MainThreadNotebookKernels implements MainThreadNotebookKernelsShape
}
}(data, this._languageService);

const listener = this._notebookKernelService.onDidChangeSelectedNotebooks(e => {
if (e.oldKernel === kernel.id) {
this._proxy.$acceptNotebookAssociation(handle, e.notebook, false);
} else if (e.newKernel === kernel.id) {
this._proxy.$acceptNotebookAssociation(handle, e.notebook, true);
}
});

const registration = this._notebookKernelService.registerKernel(kernel);
this._kernels.set(handle, [kernel, registration]);
this._kernels.set(handle, [kernel, combinedDisposable(listener, registration)]);
}

$updateKernel(handle: number, data: Partial<INotebookKernelDto2>): void {
Expand Down

0 comments on commit 6c19c00

Please sign in to comment.