Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for the session to be ready when executing a command without opening the tab #279

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions kernel-output/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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);
}
}
}
});
Expand Down
14 changes: 9 additions & 5 deletions kernel-output/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -92,7 +88,15 @@ 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);
}
}
}
});
Expand Down
Loading