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
Restore cloned output #5981
Restore cloned output #5981
Conversation
@@ -448,6 +467,7 @@ export class InstanceTracker<T extends Widget> | |||
} | |||
|
|||
private _restore: InstanceTracker.IRestoreOptions<T> | null = null; | |||
private _restored = new PromiseDelegate<void>(); |
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 appreciate the attention to alphabetization ✏️📘
}) | ||
); | ||
}); | ||
return Promise.all(promises) |
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.
The InstanceTracker#restore()
method seems like a good candidate to make async
.
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.
Agreed.
This seems like a reasonable approach. Here are two alternatives that I thought of and I'm wondering what you think about them. I don't propose you implement either, but they might be worth considering:
|
The first option would be trivial to add to /**
* A promise that resolves when the tracker has restored its notebook panels.
*/
get restored(): Promise<void> {
return this._restored.promise;
}
/**
* Restore the notebooks in this tracker.
*/
async restore(
options: InstanceTracker.IRestoreOptions<NotebookPanel>
): Promise<void> {
await super.restore(options);
this._restored.resolve(undefined);
}
private _restored = new PromiseDelegate<void>(); I think I just talked myself out of the second option, in fact. I also seem to be talking myself into the first option. |
Actually, we might even consider adding |
My thinking was roughly this: the I don't really see why we would add |
If we add it to But sure, if you think it'll be broadly useful, let's put it on the base class. |
return val; | ||
}); | ||
); | ||
this._restored.resolve(void 0); |
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.
Since we're using undefined
now, could we change this to undefined
instead of void 0
.
Also since Promise.all
resolves with an array, could we call it values
instead of a singular?
Do you think we need to guarantee that |
Sure, I think a check to make sure it is only restored once makes sense. We are still partially protected by it not being on the public interface. |
ecd59e5
to
bf70f2c
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.
Thanks!
👍
Maybe an additional test is in order for the new API surface area, even though it's minor. |
I actually sat down to do that this morning, and saw that |
Good point. Let's leave that for another PR. |
Fixes #5976.
This restores cloned output areas. It is kind of a tricky proposition, since the output areas are not available to clone until the notebook is actually loaded. Furthermore, if there are unsaved changes in the notebook (especially cell reorderings), this will restore the wrong output area, or none at all. So really, this should be considered as fixing #5976 on a reasonably-good-effort basis. It's not particularly clean, but it should work for the most common use-cases.