Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a9bbf47

Browse files
authoredMar 17, 2020
Merge pull request #107 from bcmi-labs/arduino/arduino-pro-ide#212
Wait when opening all files from a sketch folder.
2 parents 3974f2d + 2a2238b commit a9bbf47

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed
 

‎arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,10 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
534534
}
535535

536536
async openSketchFiles(uri: string): Promise<void> {
537-
this.sketchService.getSketchFiles(uri).then(uris => {
538-
for (const uri of uris) {
539-
this.editorManager.open(new URI(uri));
540-
}
541-
});
537+
const uris = await this.sketchService.getSketchFiles(uri);
538+
for (const uri of uris) {
539+
await this.editorManager.open(new URI(uri));
540+
}
542541
}
543542

544543
/**

‎arduino-ide-extension/src/browser/customization/arduino-frontend-application.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,19 @@ export class ArduinoFrontendApplication extends FrontendApplication {
2121
protected readonly editorMode: EditorMode;
2222

2323
protected async initializeLayout(): Promise<void> {
24-
return super.initializeLayout().then(() => {
25-
// If not in PRO mode, we open the sketch file with all the related files.
26-
// Otherwise, we reuse the workbench's restore functionality and we do not open anything at all.
27-
// TODO: check `otherwise`. Also, what if we check for opened editors, instead of blindly opening them?
28-
if (!this.editorMode.proMode) {
29-
this.workspaceService.roots.then(roots => {
30-
for (const root of roots) {
31-
this.fileSystem.exists(root.uri).then(exists => {
32-
if (exists) {
33-
this.frontendContribution.openSketchFiles(root.uri);
34-
}
35-
});
36-
}
37-
});
24+
await super.initializeLayout();
25+
// If not in PRO mode, we open the sketch file with all the related files.
26+
// Otherwise, we reuse the workbench's restore functionality and we do not open anything at all.
27+
// TODO: check `otherwise`. Also, what if we check for opened editors, instead of blindly opening them?
28+
if (!this.editorMode.proMode) {
29+
const roots = await this.workspaceService.roots;
30+
for (const root of roots) {
31+
const exists = await this.fileSystem.exists(root.uri);
32+
if (exists) {
33+
await this.frontendContribution.openSketchFiles(root.uri);
34+
}
3835
}
39-
});
36+
}
4037
}
4138

4239
}

0 commit comments

Comments
 (0)
Please sign in to comment.