Skip to content

make sure that we run our show code when a custom editor is shown #14022

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

Merged
Merged
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
1 change: 1 addition & 0 deletions news/2 Fixes/14016.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Have Custom Editors load on editor show unless autostart is disabled.
13 changes: 5 additions & 8 deletions src/client/datascience/interactive-common/interactiveBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,11 @@ export abstract class InteractiveBase extends WebviewPanelHost<IInteractiveWindo

// When the variable service requests a refresh, refresh our variable list
this.disposables.push(this.jupyterVariables.refreshRequired(this.refreshVariables.bind(this)));
}

public async show(preserveFocus: boolean = true): Promise<void> {
// Verify a server that matches us hasn't started already
this.createNotebookIfProviderConnectionExists().ignoreErrors();

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

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

// Then show our webpanel
await this.show();
await this.show(true);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the opposite of what this did before? I thought when creating the panel we want to steal focus?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did I fudge that up? The old show defaulted to true if you didn't specify anything. Now we just call the super class directly. Since we didn't pass anything before at this call now just pass true directly. And at a level up (native editor ect..) the default to true is just pushed up to that level to keep the same behavior before.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, yeah it's confusing. The interactive window defaults to true for preserveFocus. The webview does not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are you seeing a default set to false for the webview?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nativeEditor.ts line 243 for one. The one you changed.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry looks like it's just the other line you changed. WebViewHost doesn't default it at all.


// Add our sys info if necessary
if (file !== Identifiers.EmptyFileName) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/interactive-ipynb/nativeEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
this.previouslyNotTrusted = !this._model.isTrusted;
}

public async show(preserveFocus?: boolean) {
public async show(preserveFocus: boolean = true) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the opposite now? Are you fixing something else with this?

await this.loadPromise;
return super.show(preserveFocus);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class InteractiveWindow extends InteractiveBase implements IInteractiveWi
}
}

public async show(preserveFocus?: boolean): Promise<void> {
public async show(preserveFocus: boolean = true): Promise<void> {
await this.loadPromise;
return super.show(preserveFocus);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export class NativeEditorProvider implements INotebookEditorProvider, CustomEdit
// Get the model
const model = await this.loadModel({ file: resource });

// Load it (should already be visible)
// Load it
return this.createNotebookEditor(model, panel);
} catch (exc) {
// Send telemetry indicating a failure
Expand Down