From 2e729fc29e8c7b6a6bfd779817e9563eddc01019 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Mon, 10 Aug 2020 15:35:52 +0200 Subject: [PATCH] workaround for theia-ide/theia#7828 instead otf reloaading the current window, we open a new one and close the current. reloading the current window hangs on electron in Windows env. Signed-off-by: Akos Kitta --- .../theia/workspace/workspace-service.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/arduino-ide-extension/src/browser/theia/workspace/workspace-service.ts b/arduino-ide-extension/src/browser/theia/workspace/workspace-service.ts index 335e3758..283ab837 100644 --- a/arduino-ide-extension/src/browser/theia/workspace/workspace-service.ts +++ b/arduino-ide-extension/src/browser/theia/workspace/workspace-service.ts @@ -1,12 +1,13 @@ import { injectable, inject } from 'inversify'; import URI from '@theia/core/lib/common/uri'; +import { FileStat } from '@theia/filesystem/lib/common'; import { EditorWidget } from '@theia/editor/lib/browser'; import { LabelProvider } from '@theia/core/lib/browser/label-provider'; import { MessageService } from '@theia/core/lib/common/message-service'; import { ApplicationServer } from '@theia/core/lib/common/application-protocol'; import { FrontendApplication } from '@theia/core/lib/browser/frontend-application'; import { FocusTracker, Widget } from '@theia/core/lib/browser'; -import { WorkspaceService as TheiaWorkspaceService } from '@theia/workspace/lib/browser/workspace-service'; +import { WorkspaceService as TheiaWorkspaceService, WorkspaceInput } from '@theia/workspace/lib/browser/workspace-service'; import { ConfigService } from '../../../common/protocol/config-service'; import { SketchesService } from '../../../common/protocol/sketches-service'; import { ArduinoWorkspaceRootResolver } from '../../arduino-workspace-resolver'; @@ -109,4 +110,18 @@ export class WorkspaceService extends TheiaWorkspaceService { } } + protected openWindow(uri: FileStat, options?: WorkspaceInput): void { + const workspacePath = new URI(uri.uri).path.toString(); + try { + this.openNewWindow(workspacePath); + if (this.shouldPreserveWindow(options)) { + setTimeout(() => window.close(), 10); + } + } catch (error) { + // Fall back to reloading the current window in case the browser has blocked the new window + (this as any)._workspace = uri; + this.logger.error(error.toString()).then(() => this.reloadWindow()); + } + } + }