Skip to content

Commit e231cd6

Browse files
committed
ts kernel noops on undefined handlers if they are for language services
revert
1 parent 89a03d6 commit e231cd6

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/polyglot-notebooks-vscode-common/src/vscodeNotebookManagement.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ function hashBangConnectPrivate(clientMapper: ClientMapper, hostUri: string, ker
7777
messageHandlerMap.set(documentUriString, messageHandler);
7878
}
7979
let extensionHostToWebviewSender = KernelCommandAndEventSender.FromFunction(envelope => {
80-
controllerPostMessage({ envelope: envelope.toJson() });
80+
const commandOrEventForWebview = { envelope: envelope.toJson() };
81+
controllerPostMessage(commandOrEventForWebview);
8182
});
8283

8384
let WebviewToExtensionHostReceiver = KernelCommandAndEventReceiver.FromObservable(messageHandler);

src/polyglot-notebooks/src/kernel.ts

+27-1
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,41 @@ export class Kernel {
204204
reject(e);
205205
}
206206
} else {
207+
// hack like there is no tomorrow
208+
const shouldNoop = this.shouldNoopCommand(commandEnvelope, context);
209+
if (shouldNoop) {
210+
context.complete(commandEnvelope);
211+
}
207212
context.handlingKernel = previoudHendlingKernel;
208213
if (isRootCommand) {
209214
eventSubscription?.unsubscribe();
210215
context.dispose();
211216
}
212-
reject(new Error(`No handler found for command type ${commandEnvelope.commandType}`));
217+
if (!shouldNoop) {
218+
reject(new Error(`No handler found for command type ${commandEnvelope.commandType}`));
219+
} else {
220+
Logger.default.warn(`kernel ${this.name} done noop handling command: ${JSON.stringify(commandEnvelope)}`);
221+
resolve();
222+
}
213223
}
214224
});
215225
}
226+
private shouldNoopCommand(commandEnvelope: commandsAndEvents.KernelCommandEnvelope, context: KernelInvocationContext): boolean {
227+
228+
let shouldNoop = false;
229+
switch (commandEnvelope.commandType) {
230+
case commandsAndEvents.RequestCompletionsType:
231+
case commandsAndEvents.RequestSignatureHelpType:
232+
case commandsAndEvents.RequestDiagnosticsType:
233+
case commandsAndEvents.RequestHoverTextType:
234+
shouldNoop = true;
235+
break;
236+
default:
237+
shouldNoop = false;
238+
break;
239+
}
240+
return shouldNoop;
241+
}
216242

217243
subscribeToKernelEvents(observer: commandsAndEvents.KernelEventEnvelopeObserver): disposables.DisposableSubscription {
218244
const sub = this._eventSubject.subscribe(observer);

0 commit comments

Comments
 (0)