diff --git a/src/vs/platform/windows/electron-main/windowsService.ts b/src/vs/platform/windows/electron-main/windowsService.ts index 67c2556918d3e299d11c418c5e43ca6630c0f6da..fd3bd7688b962f19cd4a35e9e27056aba1982613 100644 --- a/src/vs/platform/windows/electron-main/windowsService.ts +++ b/src/vs/platform/windows/electron-main/windowsService.ts @@ -87,19 +87,19 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable async showMessageBox(windowId: number, options: Electron.MessageBoxOptions): Promise { this.logService.trace('windowsService#showMessageBox', windowId); - return this.withWindow(windowId, codeWindow => this.windowsMainService.showMessageBox(options, codeWindow), () => this.windowsMainService.showMessageBox(options)); + return this.withWindow(windowId, codeWindow => this.windowsMainService.showMessageBox(options, codeWindow), () => this.windowsMainService.showMessageBox(options))!; } async showSaveDialog(windowId: number, options: Electron.SaveDialogOptions): Promise { this.logService.trace('windowsService#showSaveDialog', windowId); - return this.withWindow(windowId, codeWindow => this.windowsMainService.showSaveDialog(options, codeWindow), () => this.windowsMainService.showSaveDialog(options)); + return this.withWindow(windowId, codeWindow => this.windowsMainService.showSaveDialog(options, codeWindow), () => this.windowsMainService.showSaveDialog(options))!; } async showOpenDialog(windowId: number, options: Electron.OpenDialogOptions): Promise { this.logService.trace('windowsService#showOpenDialog', windowId); - return this.withWindow(windowId, codeWindow => this.windowsMainService.showOpenDialog(options, codeWindow), () => this.windowsMainService.showOpenDialog(options)); + return this.withWindow(windowId, codeWindow => this.windowsMainService.showOpenDialog(options, codeWindow), () => this.windowsMainService.showOpenDialog(options))!; } async reloadWindow(windowId: number, args: ParsedArgs): TPromise { @@ -190,7 +190,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable async getRecentlyOpened(windowId: number): TPromise { this.logService.trace('windowsService#getRecentlyOpened', windowId); - return this.withWindow(windowId, codeWindow => this.historyService.getRecentlyOpened(codeWindow.config.workspace || codeWindow.config.folderUri, codeWindow.config.filesToOpen), () => this.historyService.getRecentlyOpened()); + return this.withWindow(windowId, codeWindow => this.historyService.getRecentlyOpened(codeWindow.config.workspace || codeWindow.config.folderUri, codeWindow.config.filesToOpen), () => this.historyService.getRecentlyOpened())!; } async newWindowTab(): TPromise { @@ -244,13 +244,13 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable async isFocused(windowId: number): TPromise { this.logService.trace('windowsService#isFocused', windowId); - return this.withWindow(windowId, codeWindow => codeWindow.win.isFocused(), () => false); + return this.withWindow(windowId, codeWindow => codeWindow.win.isFocused(), () => false)!; } async isMaximized(windowId: number): TPromise { this.logService.trace('windowsService#isMaximized', windowId); - return this.withWindow(windowId, codeWindow => codeWindow.win.isMaximized(), () => false); + return this.withWindow(windowId, codeWindow => codeWindow.win.isMaximized(), () => false)!; } async maximizeWindow(windowId: number): TPromise { @@ -457,7 +457,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable }); } - private withWindow(windowId: number, fn: (window: ICodeWindow) => T, fallback?: () => T): T { + private withWindow(windowId: number, fn: (window: ICodeWindow) => T, fallback?: () => T): T | undefined { const codeWindow = this.windowsMainService.getWindowById(windowId); if (codeWindow) { return fn(codeWindow);