From d45e4b53604ae135c878da366562c10b72d0e1a9 Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Fri, 7 Feb 2025 16:03:01 +0100 Subject: [PATCH 1/3] Await for the session to be ready --- kernel-output/src/index.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel-output/src/index.ts b/kernel-output/src/index.ts index cf4ff35c..0b537032 100644 --- a/kernel-output/src/index.ts +++ b/kernel-output/src/index.ts @@ -79,10 +79,6 @@ function activate( label: trans.__('Contact Kernel and Execute Code'), caption: trans.__('Contact Kernel and Execute Code'), execute: async () => { - // Create the panel if it does not exist - if (!panel) { - await createPanel(); - } // Prompt the user about the statement to be executed const input = await InputDialog.getText({ title: trans.__('Code to execute'), @@ -92,7 +88,16 @@ function activate( // Execute the statement if (input.button.accept) { const code = input.value || ''; - panel.execute(code); + if (!panel) { + // Create the panel if it does not exist + createPanel() + .then(async (panel) => { + await panel.session.ready; + panel.execute(code); + }); + } else { + panel.execute(code); + } } } }); From e5bca52790cca153b83628d8f7f03718294984b3 Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Tue, 18 Feb 2025 23:32:31 +0100 Subject: [PATCH 2/3] Apply prettier --- kernel-output/src/index.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel-output/src/index.ts b/kernel-output/src/index.ts index 0b537032..56ea23e2 100644 --- a/kernel-output/src/index.ts +++ b/kernel-output/src/index.ts @@ -90,11 +90,10 @@ function activate( const code = input.value || ''; if (!panel) { // Create the panel if it does not exist - createPanel() - .then(async (panel) => { - await panel.session.ready; - panel.execute(code); - }); + createPanel().then(async panel => { + await panel.session.ready; + panel.execute(code); + }); } else { panel.execute(code); } From d9a0cddee9f8b7fe6864b05c3d7ae774d2239361 Mon Sep 17 00:00:00 2001 From: Chiara Marmo Date: Wed, 26 Feb 2025 15:12:17 +0100 Subject: [PATCH 3/3] Fix code diff in README.md --- kernel-output/README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel-output/README.md b/kernel-output/README.md index fa6171e9..ebe649e0 100644 --- a/kernel-output/README.md +++ b/kernel-output/README.md @@ -240,16 +240,12 @@ to be executed by the kernel. Then you will send it to your panel for execution and display: ```ts -// src/index.ts#L78-L98 +// src/index.ts#L78-L102 commands.addCommand(CommandIDs.execute, { label: trans.__('Contact Kernel and Execute Code'), caption: trans.__('Contact Kernel and Execute Code'), execute: async () => { - // Create the panel if it does not exist - if (!panel) { - await createPanel(); - } // Prompt the user about the statement to be executed const input = await InputDialog.getText({ title: trans.__('Code to execute'), @@ -259,7 +255,15 @@ commands.addCommand(CommandIDs.execute, { // Execute the statement if (input.button.accept) { const code = input.value || ''; - panel.execute(code); + if (!panel) { + // Create the panel if it does not exist + createPanel().then(async panel => { + await panel.session.ready; + panel.execute(code); + }); + } else { + panel.execute(code); + } } } });