Skip to content

Commit d45e4b5

Browse files
committed
Await for the session to be ready
1 parent 4585387 commit d45e4b5

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

kernel-output/src/index.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ function activate(
7979
label: trans.__('Contact Kernel and Execute Code'),
8080
caption: trans.__('Contact Kernel and Execute Code'),
8181
execute: async () => {
82-
// Create the panel if it does not exist
83-
if (!panel) {
84-
await createPanel();
85-
}
8682
// Prompt the user about the statement to be executed
8783
const input = await InputDialog.getText({
8884
title: trans.__('Code to execute'),
@@ -92,7 +88,16 @@ function activate(
9288
// Execute the statement
9389
if (input.button.accept) {
9490
const code = input.value || '';
95-
panel.execute(code);
91+
if (!panel) {
92+
// Create the panel if it does not exist
93+
createPanel()
94+
.then(async (panel) => {
95+
await panel.session.ready;
96+
panel.execute(code);
97+
});
98+
} else {
99+
panel.execute(code);
100+
}
96101
}
97102
}
98103
});

0 commit comments

Comments
 (0)