diff --git a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx index 299d4cfb..cd373dbb 100644 --- a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx +++ b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx @@ -534,11 +534,10 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut } async openSketchFiles(uri: string): Promise { - 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)); + } } /** diff --git a/arduino-ide-extension/src/browser/customization/arduino-frontend-application.ts b/arduino-ide-extension/src/browser/customization/arduino-frontend-application.ts index 019677a8..ae703638 100644 --- a/arduino-ide-extension/src/browser/customization/arduino-frontend-application.ts +++ b/arduino-ide-extension/src/browser/customization/arduino-frontend-application.ts @@ -21,22 +21,19 @@ export class ArduinoFrontendApplication extends FrontendApplication { protected readonly editorMode: EditorMode; protected async initializeLayout(): Promise { - 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); + } } - }); + } } }