Skip to content

Commit

Permalink
ts kernel noops on undefined handlers if they are for language services
Browse files Browse the repository at this point in the history
revert
  • Loading branch information
colombod committed Oct 17, 2023
1 parent 89a03d6 commit e231cd6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ function hashBangConnectPrivate(clientMapper: ClientMapper, hostUri: string, ker
messageHandlerMap.set(documentUriString, messageHandler);
}
let extensionHostToWebviewSender = KernelCommandAndEventSender.FromFunction(envelope => {
controllerPostMessage({ envelope: envelope.toJson() });
const commandOrEventForWebview = { envelope: envelope.toJson() };
controllerPostMessage(commandOrEventForWebview);
});

let WebviewToExtensionHostReceiver = KernelCommandAndEventReceiver.FromObservable(messageHandler);
Expand Down
28 changes: 27 additions & 1 deletion src/polyglot-notebooks/src/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,41 @@ export class Kernel {
reject(e);
}
} else {
// hack like there is no tomorrow
const shouldNoop = this.shouldNoopCommand(commandEnvelope, context);
if (shouldNoop) {
context.complete(commandEnvelope);
}
context.handlingKernel = previoudHendlingKernel;
if (isRootCommand) {
eventSubscription?.unsubscribe();
context.dispose();
}
reject(new Error(`No handler found for command type ${commandEnvelope.commandType}`));
if (!shouldNoop) {
reject(new Error(`No handler found for command type ${commandEnvelope.commandType}`));
} else {
Logger.default.warn(`kernel ${this.name} done noop handling command: ${JSON.stringify(commandEnvelope)}`);
resolve();
}
}
});
}
private shouldNoopCommand(commandEnvelope: commandsAndEvents.KernelCommandEnvelope, context: KernelInvocationContext): boolean {

let shouldNoop = false;
switch (commandEnvelope.commandType) {
case commandsAndEvents.RequestCompletionsType:
case commandsAndEvents.RequestSignatureHelpType:
case commandsAndEvents.RequestDiagnosticsType:
case commandsAndEvents.RequestHoverTextType:
shouldNoop = true;
break;
default:
shouldNoop = false;
break;
}
return shouldNoop;
}

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

0 comments on commit e231cd6

Please sign in to comment.