提交 151de95c 编写于 作者: B Benjamin Pasero

debt - adopt host service in extension host debug service

//cc @weinand
上级 ff805b3a
...@@ -18,6 +18,7 @@ import { IWorkspaceProvider, IWorkspace } from 'vs/workbench/services/host/brows ...@@ -18,6 +18,7 @@ import { IWorkspaceProvider, IWorkspace } from 'vs/workbench/services/host/brows
import { IProcessEnvironment } from 'vs/base/common/platform'; import { IProcessEnvironment } from 'vs/base/common/platform';
import { hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces'; import { hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { IHostService } from 'vs/workbench/services/host/browser/host';
class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient implements IExtensionHostDebugService { class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient implements IExtensionHostDebugService {
...@@ -26,7 +27,8 @@ class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient i ...@@ -26,7 +27,8 @@ class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient i
constructor( constructor(
@IRemoteAgentService remoteAgentService: IRemoteAgentService, @IRemoteAgentService remoteAgentService: IRemoteAgentService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService, @IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@ILogService logService: ILogService @ILogService logService: ILogService,
@IHostService hostService: IHostService
) { ) {
const connection = remoteAgentService.getConnection(); const connection = remoteAgentService.getConnection();
let channel: IChannel; let channel: IChannel;
...@@ -49,14 +51,14 @@ class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient i ...@@ -49,14 +51,14 @@ class BrowserExtensionHostDebugService extends ExtensionHostDebugChannelClient i
// Reload window on reload request // Reload window on reload request
this._register(this.onReload(event => { this._register(this.onReload(event => {
if (environmentService.isExtensionDevelopment && environmentService.debugExtensionHost.debugId === event.sessionId) { if (environmentService.isExtensionDevelopment && environmentService.debugExtensionHost.debugId === event.sessionId) {
window.location.reload(); hostService.reload();
} }
})); }));
// Close window on close request // Close window on close request
this._register(this.onClose(event => { this._register(this.onClose(event => {
if (environmentService.isExtensionDevelopment && environmentService.debugExtensionHost.debugId === event.sessionId) { if (environmentService.isExtensionDevelopment && environmentService.debugExtensionHost.debugId === event.sessionId) {
window.close(); hostService.close();
} }
})); }));
} }
......
...@@ -413,6 +413,15 @@ export class BrowserHostService extends Disposable implements IHostService { ...@@ -413,6 +413,15 @@ export class BrowserHostService extends Disposable implements IHostService {
window.location.reload(); window.location.reload();
} }
async close(): Promise<void> {
// We know that `window.close` will trigger a shutdown
// so we update `shutdownReason` to reflect that
this.shutdownReason = HostShutdownReason.Api;
window.close();
}
//#endregion //#endregion
} }
......
...@@ -83,5 +83,10 @@ export interface IHostService { ...@@ -83,5 +83,10 @@ export interface IHostService {
*/ */
reload(): Promise<void>; reload(): Promise<void>;
/**
* Attempt to close the active window.
*/
close(): Promise<void>;
//#endregion //#endregion
} }
...@@ -106,6 +106,10 @@ export class NativeHostService extends Disposable implements IHostService { ...@@ -106,6 +106,10 @@ export class NativeHostService extends Disposable implements IHostService {
return this.nativeHostService.reload(); return this.nativeHostService.reload();
} }
close(): Promise<void> {
return this.nativeHostService.closeWindow();
}
//#endregion //#endregion
} }
......
...@@ -1046,6 +1046,7 @@ export class TestHostService implements IHostService { ...@@ -1046,6 +1046,7 @@ export class TestHostService implements IHostService {
async restart(): Promise<void> { } async restart(): Promise<void> { }
async reload(): Promise<void> { } async reload(): Promise<void> { }
async close(): Promise<void> { }
async focus(options?: { force: boolean }): Promise<void> { } async focus(options?: { force: boolean }): Promise<void> { }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册