Spectrum is now read-only. Learn more about the decision in our official announcement.


Eclipse Theia - Cloud & Desktop IDE


async Widget.restoreState?

December 3, 2019 at 6:27pm

async Widget.restoreState?

December 3, 2019 at 6:27pm (Edited 3 years ago)
I want to prevent the IDE from opening new shells when restoring terminals in the UI. I want to know how to handle async events in the restoreState method, or if there is a way to prevent a widget from being restored even before based on some async test?

December 4, 2019 at 4:40am
Could you share how async restoreState would look like?
Could you avoid storing state in the first place?
If an empty object is stored as state then a widget gets disposed during restoring

December 5, 2019 at 3:36pm
To be fair I didn't really know how the async restoreState would work, but essentially the issue is that state should be stored, but when about to recreate the widget (before or while restoring) we need to asynchronously check that the state is also valid on the backend (for terminals, this means not recreating terminals if the remote process doesn't exist anymore, maybe the backend restarted). Thanks for the pointers.
it does not seem that async restoreState is necessary, it can trigger async operation without awaiting to check whether terminal exist and if it does not then dispose the widget or do something else. It could that you need a guard that recreation does not happen.
Yes, does such a "re-creation guard" hook already exists?

December 6, 2019 at 9:46am
I don't know, please have a look at TerminalWidget. I don't think we need a generic one for widgets.