From c00ce5968afe80206243125c70c01c2290770d4a Mon Sep 17 00:00:00 2001 From: Michael Lively Date: Fri, 2 Aug 2024 11:33:28 -0700 Subject: [PATCH 1/2] logging for context key issues --- src/standalone/context/activeEditorContext.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/standalone/context/activeEditorContext.ts b/src/standalone/context/activeEditorContext.ts index 9059eee5ef5..97f6f09b33c 100644 --- a/src/standalone/context/activeEditorContext.ts +++ b/src/standalone/context/activeEditorContext.ts @@ -15,6 +15,7 @@ import { getNotebookMetadata, isJupyterNotebook } from '../../platform/common/ut import { isPythonNotebook } from '../../kernels/helpers'; import { IControllerRegistration } from '../../notebooks/controllers/types'; import { IJupyterServerProviderRegistry } from '../../kernels/jupyter/types'; +import { logger } from '../../platform/logging'; /** * Tracks a lot of the context keys needed in the extension. @@ -163,6 +164,9 @@ export class ActiveEditorContextService implements IExtensionSyncActivationServi const canInterrupt = kernel.status === 'busy'; this.canInterruptNotebookKernelContext.set(!!canInterrupt).catch(noop); } else { + logger.debug('Context Key jupyter.notebookeditor.canrestartNotebookkernel = FALSE'); + logger.debug('Active Editor Notebook Type: ', activeEditor ? activeEditor.notebook.notebookType : 'No Active Notebook'); + logger.debug('Kernel: ', activeEditor ? this.kernelProvider.get(activeEditor.notebook) : 'No Active Notebook'); this.canRestartNotebookKernelContext.set(false).catch(noop); this.canInterruptNotebookKernelContext.set(false).catch(noop); } @@ -196,6 +200,9 @@ export class ActiveEditorContextService implements IExtensionSyncActivationServi if (document && isJupyterNotebook(document) && this.controllers.getSelected(document)) { this.isJupyterKernelSelected.set(true).catch(noop); } else { + logger.debug('Context Key isJupyter = FALSE'); + logger.debug('isJupyterNotebook: ', document ? (isJupyterNotebook(document)) : 'No NotebookDocument'); + logger.debug('controllers.getSelected: ', document ? (this.controllers.getSelected(document)) : 'No NotebookDocument'); this.isJupyterKernelSelected.set(false).catch(noop); } } From 75d6010a4d985493a50ba5edd2a027251774d656 Mon Sep 17 00:00:00 2001 From: Michael Lively Date: Fri, 2 Aug 2024 11:43:52 -0700 Subject: [PATCH 2/2] prettier formatting --- src/standalone/context/activeEditorContext.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/standalone/context/activeEditorContext.ts b/src/standalone/context/activeEditorContext.ts index 97f6f09b33c..4c9b4da0f1d 100644 --- a/src/standalone/context/activeEditorContext.ts +++ b/src/standalone/context/activeEditorContext.ts @@ -165,8 +165,14 @@ export class ActiveEditorContextService implements IExtensionSyncActivationServi this.canInterruptNotebookKernelContext.set(!!canInterrupt).catch(noop); } else { logger.debug('Context Key jupyter.notebookeditor.canrestartNotebookkernel = FALSE'); - logger.debug('Active Editor Notebook Type: ', activeEditor ? activeEditor.notebook.notebookType : 'No Active Notebook'); - logger.debug('Kernel: ', activeEditor ? this.kernelProvider.get(activeEditor.notebook) : 'No Active Notebook'); + logger.debug( + 'Active Editor Notebook Type: ', + activeEditor ? activeEditor.notebook.notebookType : 'No Active Notebook' + ); + logger.debug( + 'Kernel: ', + activeEditor ? this.kernelProvider.get(activeEditor.notebook) : 'No Active Notebook' + ); this.canRestartNotebookKernelContext.set(false).catch(noop); this.canInterruptNotebookKernelContext.set(false).catch(noop); } @@ -201,8 +207,11 @@ export class ActiveEditorContextService implements IExtensionSyncActivationServi this.isJupyterKernelSelected.set(true).catch(noop); } else { logger.debug('Context Key isJupyter = FALSE'); - logger.debug('isJupyterNotebook: ', document ? (isJupyterNotebook(document)) : 'No NotebookDocument'); - logger.debug('controllers.getSelected: ', document ? (this.controllers.getSelected(document)) : 'No NotebookDocument'); + logger.debug('isJupyterNotebook: ', document ? isJupyterNotebook(document) : 'No NotebookDocument'); + logger.debug( + 'controllers.getSelected: ', + document ? this.controllers.getSelected(document) : 'No NotebookDocument' + ); this.isJupyterKernelSelected.set(false).catch(noop); } }