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>
This commit is contained in:
Akos Kitta 2020-08-10 15:35:52 +02:00
parent bc4c3e04f5
commit 2e729fc29e

View File

@ -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());
}
}
}