|
1 | 1 | import { injectable, inject } from 'inversify';
|
2 | 2 | import URI from '@theia/core/lib/common/uri';
|
| 3 | +import { FileStat } from '@theia/filesystem/lib/common'; |
3 | 4 | import { EditorWidget } from '@theia/editor/lib/browser';
|
4 | 5 | import { LabelProvider } from '@theia/core/lib/browser/label-provider';
|
5 | 6 | import { MessageService } from '@theia/core/lib/common/message-service';
|
6 | 7 | import { ApplicationServer } from '@theia/core/lib/common/application-protocol';
|
7 | 8 | import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
|
8 | 9 | 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'; |
10 | 11 | import { ConfigService } from '../../../common/protocol/config-service';
|
11 | 12 | import { SketchesService } from '../../../common/protocol/sketches-service';
|
12 | 13 | import { ArduinoWorkspaceRootResolver } from '../../arduino-workspace-resolver';
|
@@ -109,4 +110,18 @@ export class WorkspaceService extends TheiaWorkspaceService {
|
109 | 110 | }
|
110 | 111 | }
|
111 | 112 |
|
| 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 | + |
112 | 127 | }
|
0 commit comments