Wait when opening all files from a sketch folder.

This commit is a temporary workaround for eclipse-theia/theia#6298.

Closes arduino/arduino-pro-ide#212.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2020-03-12 14:57:38 +01:00
parent 8cf019bc07
commit 2a2238bb82
2 changed files with 16 additions and 20 deletions

View File

@ -534,11 +534,10 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
}
async openSketchFiles(uri: string): Promise<void> {
this.sketchService.getSketchFiles(uri).then(uris => {
for (const uri of uris) {
this.editorManager.open(new URI(uri));
}
});
const uris = await this.sketchService.getSketchFiles(uri);
for (const uri of uris) {
await this.editorManager.open(new URI(uri));
}
}
/**

View File

@ -21,22 +21,19 @@ export class ArduinoFrontendApplication extends FrontendApplication {
protected readonly editorMode: EditorMode;
protected async initializeLayout(): Promise<void> {
return super.initializeLayout().then(() => {
// If not in PRO mode, we open the sketch file with all the related files.
// Otherwise, we reuse the workbench's restore functionality and we do not open anything at all.
// TODO: check `otherwise`. Also, what if we check for opened editors, instead of blindly opening them?
if (!this.editorMode.proMode) {
this.workspaceService.roots.then(roots => {
for (const root of roots) {
this.fileSystem.exists(root.uri).then(exists => {
if (exists) {
this.frontendContribution.openSketchFiles(root.uri);
}
});
}
});
await super.initializeLayout();
// If not in PRO mode, we open the sketch file with all the related files.
// Otherwise, we reuse the workbench's restore functionality and we do not open anything at all.
// TODO: check `otherwise`. Also, what if we check for opened editors, instead of blindly opening them?
if (!this.editorMode.proMode) {
const roots = await this.workspaceService.roots;
for (const root of roots) {
const exists = await this.fileSystem.exists(root.uri);
if (exists) {
await this.frontendContribution.openSketchFiles(root.uri);
}
}
});
}
}
}