Make sure the files from the sketch folder are opened at startup.

Previously, we opened the files only in classic mode.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2020-07-15 15:09:43 +02:00
parent 2bd9eef146
commit f392ce752d

View File

@ -3,7 +3,6 @@ import { FileSystem } from '@theia/filesystem/lib/common/filesystem';
import { CommandService } from '@theia/core/lib/common/command';
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
import { EditorMode } from '../editor-mode';
import { ArduinoCommands } from '../arduino-commands';
@injectable()
@ -18,21 +17,13 @@ export class ArduinoFrontendApplication extends FrontendApplication {
@inject(CommandService)
protected readonly commandService: CommandService;
@inject(EditorMode)
protected readonly editorMode: EditorMode;
protected async initializeLayout(): Promise<void> {
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.commandService.executeCommand(ArduinoCommands.OPEN_SKETCH_FILES.id, root.uri);
}
const roots = await this.workspaceService.roots;
for (const root of roots) {
const exists = await this.fileSystem.exists(root.uri);
if (exists) {
await this.commandService.executeCommand(ArduinoCommands.OPEN_SKETCH_FILES.id, root.uri);
}
}
}