Skip to content

Commit 221c0d5

Browse files
IanMatthewHuffIan Huff
and
Ian Huff
authored
make sure that we run our show code when a custom editor is shown (#14022)
* make sure that we run our show code when a custom editor is shown * Trigger notebook load in the constructor, not show Co-authored-by: Ian Huff <[email protected]>
1 parent a531cba commit 221c0d5

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

news/2 Fixes/14016.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Have Custom Editors load on editor show unless autostart is disabled.

src/client/datascience/interactive-common/interactiveBase.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,11 @@ export abstract class InteractiveBase extends WebviewPanelHost<IInteractiveWindo
216216

217217
// When the variable service requests a refresh, refresh our variable list
218218
this.disposables.push(this.jupyterVariables.refreshRequired(this.refreshVariables.bind(this)));
219-
}
220-
221-
public async show(preserveFocus: boolean = true): Promise<void> {
222-
// Verify a server that matches us hasn't started already
223-
this.createNotebookIfProviderConnectionExists().ignoreErrors();
224219

225-
// Show our web panel.
226-
return super.show(preserveFocus);
220+
// If we have already auto started our server then we can go ahead and try to create a notebook on construction
221+
setTimeout(() => {
222+
this.createNotebookIfProviderConnectionExists().ignoreErrors();
223+
}, 0);
227224
}
228225

229226
// tslint:disable-next-line: no-any no-empty cyclomatic-complexity max-func-body-length
@@ -610,7 +607,7 @@ export abstract class InteractiveBase extends WebviewPanelHost<IInteractiveWindo
610607
await this.ensureDarkSet();
611608

612609
// Then show our webpanel
613-
await this.show();
610+
await this.show(true);
614611

615612
// Add our sys info if necessary
616613
if (file !== Identifiers.EmptyFileName) {

src/client/datascience/interactive-ipynb/nativeEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
240240
this.previouslyNotTrusted = !this._model.isTrusted;
241241
}
242242

243-
public async show(preserveFocus?: boolean) {
243+
public async show(preserveFocus: boolean = true) {
244244
await this.loadPromise;
245245
return super.show(preserveFocus);
246246
}

src/client/datascience/interactive-window/interactiveWindow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export class InteractiveWindow extends InteractiveBase implements IInteractiveWi
197197
}
198198
}
199199

200-
public async show(preserveFocus?: boolean): Promise<void> {
200+
public async show(preserveFocus: boolean = true): Promise<void> {
201201
await this.loadPromise;
202202
return super.show(preserveFocus);
203203
}

src/client/datascience/notebookStorage/nativeEditorProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export class NativeEditorProvider implements INotebookEditorProvider, CustomEdit
276276
// Get the model
277277
const model = await this.loadModel({ file: resource });
278278

279-
// Load it (should already be visible)
279+
// Load it
280280
return this.createNotebookEditor(model, panel);
281281
} catch (exc) {
282282
// Send telemetry indicating a failure

0 commit comments

Comments
 (0)