-
Notifications
You must be signed in to change notification settings - Fork 293
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
fix interactive window restore #11575
Conversation
Codecov Report
@@ Coverage Diff @@
## main #11575 +/- ##
=======================================
Coverage 62% 62%
=======================================
Files 482 486 +4
Lines 34464 34594 +130
Branches 5602 5614 +12
=======================================
+ Hits 21634 21732 +98
- Misses 10763 10790 +27
- Partials 2067 2072 +5
|
}; | ||
// don't start the kernel if the IW has only been restored from a previous session | ||
if (this.initialized) { | ||
this.startKernel().ignoreErrors(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this event is what sets the controller on restore. It is called even when the controller is initially set, and will also take care of the case that the user changes the controller before running any cells
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid that checking visibleNotebookEditors
might not work with hidden IW tabs.
66c93d4
to
c8048c3
Compare
c8048c3
to
d1d3714
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me. Only nit about typings check.
@@ -95,7 +95,7 @@ export class InteractiveWindow implements IInteractiveWindowLoadable { | |||
return this._submitters; | |||
} | |||
public get notebookDocument(): NotebookDocument { | |||
return this.notebookEditor.notebook; | |||
return this.notebookEditor?.notebook; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this change the typing to notebookDocument: NotebookDocument | undefined
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually was already that, but I suppose I should go through with the rest of the corrections for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd rather tackle this in debt week - there is a lot of code in InteractiveWindow
that relies on notebookDocument not being null, which would add a lot of extra undefined
checking. Now that I've poked around quite a bit this iteration, I have a better idea of what could be done, including not relying on the editor to be the same throughout the lifetime of the IW object (separate issue).
const document = await workspace.openNotebookDocument(this.notebookEditorOrTab.input.uri); | ||
const editor = await window.showNotebookDocument(document, { | ||
viewColumn: this.notebookEditorOrTab.group.viewColumn | ||
public async ensureInitialized() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably use some typescript type checking trick here since notebookDocument
can be undefined
:
interface IResolvedInteractiveWindow {
notebookDocument: NotebookDocument;
}
class InteractiveWindow {
ensureInitialized(): this is IResolvedInteractiveWindow;
}
Fixes #11574
part of #10808
windows
API instead of calling an API that might end up creating a new one.