|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information. |
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | | -import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor, IpcMainEvent } from 'electron'; |
| 6 | +import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor, IpcMainEvent, BrowserWindow } from 'electron'; |
7 | 7 | import { IProcessEnvironment, isWindows, isMacintosh } from 'vs/base/common/platform'; |
8 | 8 | import { WindowsManager } from 'vs/code/electron-main/windows'; |
9 | 9 | import { OpenContext, IWindowOpenable } from 'vs/platform/windows/common/windows'; |
@@ -78,13 +78,16 @@ import { IElectronService } from 'vs/platform/electron/node/electron'; |
78 | 78 | import { ElectronMainService } from 'vs/platform/electron/electron-main/electronMainService'; |
79 | 79 | import { ISharedProcessMainService, SharedProcessMainService } from 'vs/platform/ipc/electron-main/sharedProcessMainService'; |
80 | 80 | import { assign } from 'vs/base/common/objects'; |
| 81 | +import { IDialogMainService, DialogMainService } from 'vs/platform/dialogs/electron-main/dialogs'; |
| 82 | +import { withNullAsUndefined } from 'vs/base/common/types'; |
81 | 83 |
|
82 | 84 | export class CodeApplication extends Disposable { |
83 | 85 |
|
84 | 86 | private static readonly MACHINE_ID_KEY = 'telemetry.machineId'; |
85 | 87 | private static readonly TRUE_MACHINE_ID_KEY = 'telemetry.trueMachineId'; |
86 | 88 |
|
87 | 89 | private windowsMainService: IWindowsMainService | undefined; |
| 90 | + private dialogMainService: IDialogMainService | undefined; |
88 | 91 |
|
89 | 92 | constructor( |
90 | 93 | private readonly mainIpcServer: Server, |
@@ -449,6 +452,7 @@ export class CodeApplication extends Disposable { |
449 | 452 | } |
450 | 453 |
|
451 | 454 | services.set(IWindowsMainService, new SyncDescriptor(WindowsManager, [machineId, this.userEnv])); |
| 455 | + services.set(IDialogMainService, new SyncDescriptor(DialogMainService)); |
452 | 456 | services.set(ISharedProcessMainService, new SyncDescriptor(SharedProcessMainService, [sharedProcess])); |
453 | 457 | services.set(ILaunchMainService, new SyncDescriptor(LaunchMainService)); |
454 | 458 |
|
@@ -503,13 +507,13 @@ export class CodeApplication extends Disposable { |
503 | 507 |
|
504 | 508 | contentTracing.stopRecording(join(homedir(), `${product.applicationName}-${Math.random().toString(16).slice(-4)}.trace.txt`), path => { |
505 | 509 | if (!timeout) { |
506 | | - if (this.windowsMainService) { |
507 | | - this.windowsMainService.showMessageBox({ |
| 510 | + if (this.dialogMainService) { |
| 511 | + this.dialogMainService.showMessageBox({ |
508 | 512 | type: 'info', |
509 | 513 | message: localize('trace.message', "Successfully created trace."), |
510 | 514 | detail: localize('trace.detail', "Please create an issue and manually attach the following file:\n{0}", path), |
511 | 515 | buttons: [localize('trace.ok', "Ok")] |
512 | | - }, this.windowsMainService.getLastActiveWindow()); |
| 516 | + }, withNullAsUndefined(BrowserWindow.getFocusedWindow())); |
513 | 517 | } |
514 | 518 | } else { |
515 | 519 | this.logService.info(`Tracing: data recorded (after 30s timeout) to ${path}`); |
@@ -580,6 +584,7 @@ export class CodeApplication extends Disposable { |
580 | 584 |
|
581 | 585 | // Propagate to clients |
582 | 586 | const windowsMainService = this.windowsMainService = accessor.get(IWindowsMainService); |
| 587 | + this.dialogMainService = accessor.get(IDialogMainService); |
583 | 588 |
|
584 | 589 | // Create a URL handler to open file URIs in the active window |
585 | 590 | const environmentService = accessor.get(IEnvironmentService); |
|
0 commit comments