Skip to content

Commit 2e729fc

Browse files
author
Akos Kitta
committed
workaround for eclipse-theia/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 <kittaakos@typefox.io>
1 parent bc4c3e0 commit 2e729fc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

arduino-ide-extension/src/browser/theia/workspace/workspace-service.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { injectable, inject } from 'inversify';
22
import URI from '@theia/core/lib/common/uri';
3+
import { FileStat } from '@theia/filesystem/lib/common';
34
import { EditorWidget } from '@theia/editor/lib/browser';
45
import { LabelProvider } from '@theia/core/lib/browser/label-provider';
56
import { MessageService } from '@theia/core/lib/common/message-service';
67
import { ApplicationServer } from '@theia/core/lib/common/application-protocol';
78
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
89
import { FocusTracker, Widget } from '@theia/core/lib/browser';
9-
import { WorkspaceService as TheiaWorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
10+
import { WorkspaceService as TheiaWorkspaceService, WorkspaceInput } from '@theia/workspace/lib/browser/workspace-service';
1011
import { ConfigService } from '../../../common/protocol/config-service';
1112
import { SketchesService } from '../../../common/protocol/sketches-service';
1213
import { ArduinoWorkspaceRootResolver } from '../../arduino-workspace-resolver';
@@ -109,4 +110,18 @@ export class WorkspaceService extends TheiaWorkspaceService {
109110
}
110111
}
111112

113+
protected openWindow(uri: FileStat, options?: WorkspaceInput): void {
114+
const workspacePath = new URI(uri.uri).path.toString();
115+
try {
116+
this.openNewWindow(workspacePath);
117+
if (this.shouldPreserveWindow(options)) {
118+
setTimeout(() => window.close(), 10);
119+
}
120+
} catch (error) {
121+
// Fall back to reloading the current window in case the browser has blocked the new window
122+
(this as any)._workspace = uri;
123+
this.logger.error(error.toString()).then(() => this.reloadWindow());
124+
}
125+
}
126+
112127
}

0 commit comments

Comments
 (0)