diff --git a/src/vs/workbench/contrib/debug/browser/extensionHostDebugService.ts b/src/vs/workbench/contrib/debug/browser/extensionHostDebugService.ts index 8d7b89429d5be45059bdb0d752cc52547c3ca7fb..a42bdff4488de5cb2a582c5b8afcb4425bd202ea 100644 --- a/src/vs/workbench/contrib/debug/browser/extensionHostDebugService.ts +++ b/src/vs/workbench/contrib/debug/browser/extensionHostDebugService.ts @@ -18,6 +18,7 @@ import { IWorkspaceProvider, IWorkspace } from 'vs/workbench/services/host/brows import { IProcessEnvironment } from 'vs/base/common/platform'; import { hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces'; import { ILogService } from 'vs/platform/log/common/log'; +import { IHostService } from 'vs/workbench/services/host/browser/host'; class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient implements IExtensionHostDebugService { @@ -26,7 +27,8 @@ class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient i constructor( @IRemoteAgentService remoteAgentService: IRemoteAgentService, @IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService, - @ILogService logService: ILogService + @ILogService logService: ILogService, + @IHostService hostService: IHostService ) { const connection = remoteAgentService.getConnection(); let channel: IChannel; @@ -49,14 +51,14 @@ class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient i // Reload window on reload request this._register(this.onReload(event => { if (environmentService.isExtensionDevelopment && environmentService.debugExtensionHost.debugId === event.sessionId) { - window.location.reload(); + hostService.reload(); } })); // Close window on close request this._register(this.onClose(event => { if (environmentService.isExtensionDevelopment && environmentService.debugExtensionHost.debugId === event.sessionId) { - window.close(); + hostService.close(); } })); } diff --git a/src/vs/workbench/services/host/browser/browserHostService.ts b/src/vs/workbench/services/host/browser/browserHostService.ts index bc224d31267cd85612239e6b4f6d4d507d0f1c3b..530133592778dad6fdc09f99c60fe9438d381235 100644 --- a/src/vs/workbench/services/host/browser/browserHostService.ts +++ b/src/vs/workbench/services/host/browser/browserHostService.ts @@ -413,6 +413,15 @@ export class BrowserHostService extends Disposable implements IHostService { window.location.reload(); } + async close(): Promise { + + // We know that `window.close` will trigger a shutdown + // so we update `shutdownReason` to reflect that + this.shutdownReason = HostShutdownReason.Api; + + window.close(); + } + //#endregion } diff --git a/src/vs/workbench/services/host/browser/host.ts b/src/vs/workbench/services/host/browser/host.ts index 222da33fcdece39f0f6143b25d6aa2fdb14b9ba4..db8a05c426291f2627b8ee6c3ca2f80726896b85 100644 --- a/src/vs/workbench/services/host/browser/host.ts +++ b/src/vs/workbench/services/host/browser/host.ts @@ -83,5 +83,10 @@ export interface IHostService { */ reload(): Promise; + /** + * Attempt to close the active window. + */ + close(): Promise; + //#endregion } diff --git a/src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts b/src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts index cef9b4614e81840125e9fbbc621530c778cbec79..005f5d42629bb22e3834f3de7096a65d7e644a79 100644 --- a/src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts +++ b/src/vs/workbench/services/host/electron-sandbox/nativeHostService.ts @@ -106,6 +106,10 @@ export class NativeHostService extends Disposable implements IHostService { return this.nativeHostService.reload(); } + close(): Promise { + return this.nativeHostService.closeWindow(); + } + //#endregion } diff --git a/src/vs/workbench/test/browser/workbenchTestServices.ts b/src/vs/workbench/test/browser/workbenchTestServices.ts index 34e84902831720905f9c105e0121111bcbd5f740..b59d073c566a023384511446851af7895c23dce0 100644 --- a/src/vs/workbench/test/browser/workbenchTestServices.ts +++ b/src/vs/workbench/test/browser/workbenchTestServices.ts @@ -1046,6 +1046,7 @@ export class TestHostService implements IHostService { async restart(): Promise { } async reload(): Promise { } + async close(): Promise { } async focus(options?: { force: boolean }): Promise { }