[uncaught exception in main]: Cannot read properties of undefined (reading 'focus') (fix #176211) (#176213)

This commit is contained in:
Benjamin Pasero
2023-03-06 09:10:28 +01:00
committed by GitHub
parent 99002e1d01
commit 2125515049
2 changed files with 11 additions and 9 deletions
+7 -6
View File
@@ -115,6 +115,7 @@ import { IInitialProtocolUrls, IProtocolUrl } from 'vs/platform/url/electron-mai
import { massageMessageBoxOptions } from 'vs/platform/dialogs/common/dialogs';
import { IUtilityProcessWorkerMainService, UtilityProcessWorkerMainService } from 'vs/platform/utilityProcess/electron-main/utilityProcessWorkerMainService';
import { ipcUtilityProcessWorkerChannelName } from 'vs/platform/utilityProcess/common/utilityProcessWorkerService';
import { firstOrDefault } from 'vs/base/common/arrays';
/**
* The main VS Code application. There will only ever be one instance,
@@ -785,16 +786,16 @@ export class CodeApplication extends Disposable {
if (windowOpenableFromProtocolUrl) {
this.logService.trace('app#handleProtocolUrl() opening protocol url as window:', windowOpenableFromProtocolUrl, uri.toString(true));
const [window] = await windowsMainService.open({
const window = firstOrDefault(await windowsMainService.open({
context: OpenContext.API,
cli: { ...this.environmentMainService.args },
urisToOpen: [windowOpenableFromProtocolUrl],
forceNewWindow: shouldOpenInNewWindow,
gotoLineMode: true
// remoteAuthority: will be determined based on windowOpenableFromProtocolUrl
});
}));
window.focus(); // this should help ensuring that the right window gets focus when multiple are opened
window?.focus(); // this should help ensuring that the right window gets focus when multiple are opened
return true;
}
@@ -803,16 +804,16 @@ export class CodeApplication extends Disposable {
if (shouldOpenInNewWindow) {
this.logService.trace('app#handleProtocolUrl() opening empty window and passing in protocol url:', uri.toString(true));
const [window] = await windowsMainService.open({
const window = firstOrDefault(await windowsMainService.open({
context: OpenContext.API,
cli: { ...this.environmentMainService.args },
forceNewWindow: true,
forceEmpty: true,
gotoLineMode: true,
remoteAuthority: getRemoteAuthority(uri)
});
}));
await window.ready();
await window?.ready();
return urlService.open(uri, options);
}
@@ -50,6 +50,7 @@ import { resolveCommonProperties } from 'vs/platform/telemetry/common/commonProp
import { hostname, release } from 'os';
import { resolveMachineId } from 'vs/platform/telemetry/electron-main/telemetryUtils';
import { ILoggerMainService } from 'vs/platform/log/electron-main/loggerService';
import { firstOrDefault } from 'vs/base/common/arrays';
export interface IWindowCreationOptions {
readonly state: IWindowState;
@@ -881,7 +882,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
// Delegate to windows service
const [window] = await this.windowsMainService.open({
const window = firstOrDefault(await this.windowsMainService.open({
context: OpenContext.API,
userEnv: this._config.userEnv,
cli: {
@@ -892,8 +893,8 @@ export class CodeWindow extends Disposable implements ICodeWindow {
forceEmpty,
forceNewWindow: true,
remoteAuthority: this.remoteAuthority
});
window.focus();
}));
window?.focus();
}
}