File tree Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ You can then add the commands to the palette by iterating
195
195
on a list:
196
196
197
197
``` ts
198
- // src/index.ts#L100-L103
198
+ // src/index.ts#L104-L107
199
199
200
200
// add items in command palette and menu
201
201
[CommandIDs .create , CommandIDs .execute ].forEach (command => {
@@ -240,16 +240,12 @@ to be executed by the kernel. Then you will send it to your panel for execution
240
240
and display:
241
241
242
242
``` ts
243
- // src/index.ts#L78-L98
243
+ // src/index.ts#L78-L102
244
244
245
245
commands .addCommand (CommandIDs .execute , {
246
246
label: trans .__ (' Contact Kernel and Execute Code' ),
247
247
caption: trans .__ (' Contact Kernel and Execute Code' ),
248
248
execute : async () => {
249
- // Create the panel if it does not exist
250
- if (! panel ) {
251
- await createPanel ();
252
- }
253
249
// Prompt the user about the statement to be executed
254
250
const input = await InputDialog .getText ({
255
251
title: trans .__ (' Code to execute' ),
@@ -259,7 +255,15 @@ commands.addCommand(CommandIDs.execute, {
259
255
// Execute the statement
260
256
if (input .button .accept ) {
261
257
const code = input .value || ' ' ;
262
- panel .execute (code );
258
+ if (! panel ) {
259
+ // Create the panel if it does not exist
260
+ createPanel ().then (async panel => {
261
+ await panel .session .ready ;
262
+ panel .execute (code );
263
+ });
264
+ } else {
265
+ panel .execute (code );
266
+ }
263
267
}
264
268
}
265
269
});
Original file line number Diff line number Diff line change @@ -79,10 +79,6 @@ function activate(
79
79
label : trans . __ ( 'Contact Kernel and Execute Code' ) ,
80
80
caption : trans . __ ( 'Contact Kernel and Execute Code' ) ,
81
81
execute : async ( ) => {
82
- // Create the panel if it does not exist
83
- if ( ! panel ) {
84
- await createPanel ( ) ;
85
- }
86
82
// Prompt the user about the statement to be executed
87
83
const input = await InputDialog . getText ( {
88
84
title : trans . __ ( 'Code to execute' ) ,
@@ -92,7 +88,15 @@ function activate(
92
88
// Execute the statement
93
89
if ( input . button . accept ) {
94
90
const code = input . value || '' ;
95
- panel . execute ( code ) ;
91
+ if ( ! panel ) {
92
+ // Create the panel if it does not exist
93
+ createPanel ( ) . then ( async panel => {
94
+ await panel . session . ready ;
95
+ panel . execute ( code ) ;
96
+ } ) ;
97
+ } else {
98
+ panel . execute ( code ) ;
99
+ }
96
100
}
97
101
}
98
102
} ) ;
You can’t perform that action at this time.
0 commit comments