Skip to content

Commit 1c6938e

Browse files
author
Benjamin Pasero
committed
debt - reload() to host service
1 parent e1f4b03 commit 1c6938e

32 files changed

Lines changed: 93 additions & 104 deletions

File tree

src/vs/platform/electron/electron-main/electronMainService.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ export class ElectronMainService implements IElectronService {
8383
return this.lifecycleMainService.relaunch(options);
8484
}
8585

86+
async reload(): Promise<void> {
87+
const window = this.window;
88+
if (window) {
89+
return this.windowsMainService.reload(window);
90+
}
91+
}
92+
8693
async openDevTools(options?: OpenDevToolsOptions): Promise<void> {
8794
const window = this.window;
8895
if (window) {

src/vs/platform/electron/node/electron.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ export interface IElectronService {
3030

3131
// OS
3232
showItemInFolder(path: string): Promise<void>;
33+
34+
// Lifecycle
3335
relaunch(options?: { addArgs?: string[], removeArgs?: string[] }): Promise<void>;
36+
reload(): Promise<void>;
3437

3538
// Development
3639
openDevTools(options?: OpenDevToolsOptions): Promise<void>;

src/vs/platform/windows/common/windows.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export interface IWindowsService {
9494
readonly onWindowUnmaximize: Event<number>;
9595
readonly onRecentlyOpenedChange: Event<void>;
9696

97-
reloadWindow(windowId: number, args?: ParsedArgs): Promise<void>;
9897
closeWorkspace(windowId: number): Promise<void>;
9998
enterWorkspace(windowId: number, path: URI): Promise<IEnterWorkspaceResult | undefined>;
10099
setRepresentedFilename(windowId: number, fileName: string): Promise<void>;
@@ -196,7 +195,6 @@ export interface IWindowService {
196195

197196
readonly windowId: number;
198197

199-
reloadWindow(args?: ParsedArgs): Promise<void>;
200198
closeWorkspace(): Promise<void>;
201199
updateTouchBar(items: ISerializableCommandAction[][]): Promise<void>;
202200
enterWorkspace(path: URI): Promise<IEnterWorkspaceResult | undefined>;

src/vs/platform/windows/common/windowsIpc.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export class WindowsChannel implements IServerChannel {
4343

4444
call(_: unknown, command: string, arg?: any): Promise<any> {
4545
switch (command) {
46-
case 'reloadWindow': return this.service.reloadWindow(arg[0], arg[1]);
4746
case 'closeWorkspace': return this.service.closeWorkspace(arg);
4847
case 'enterWorkspace': return this.service.enterWorkspace(arg[0], URI.revive(arg[1]));
4948
case 'setRepresentedFilename': return this.service.setRepresentedFilename(arg[0], arg[1]);

src/vs/platform/windows/electron-browser/windowsService.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ export class WindowsService implements IWindowsService {
3131
this.channel = mainProcessService.getChannel('windows');
3232
}
3333

34-
reloadWindow(windowId: number, args?: ParsedArgs): Promise<void> {
35-
return this.channel.call('reloadWindow', [windowId, args]);
36-
}
37-
3834
closeWorkspace(windowId: number): Promise<void> {
3935
return this.channel.call('closeWorkspace', windowId);
4036
}

src/vs/platform/windows/electron-main/legacyWindowsMainService.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ export class LegacyWindowsMainService extends Disposable implements IWindowsServ
7575
return this.withWindow(windowId, codeWindow => this.windowsMainService.showOpenDialog(options, codeWindow), () => this.windowsMainService.showOpenDialog(options))!;
7676
}
7777

78-
async reloadWindow(windowId: number, args: ParsedArgs): Promise<void> {
79-
this.logService.trace('windowsService#reloadWindow', windowId);
80-
81-
return this.withWindow(windowId, codeWindow => this.windowsMainService.reload(codeWindow, args));
82-
}
83-
8478
async updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): Promise<void> {
8579
this.logService.trace('windowsService#updateTouchBar', windowId);
8680

src/vs/platform/windows/electron-main/windows.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export interface ICodeWindow {
5050

5151
addTabbedWindow(window: ICodeWindow): void;
5252

53-
load(config: IWindowConfiguration, isReload?: boolean, disableExtensions?: boolean): void;
53+
load(config: IWindowConfiguration, isReload?: boolean): void;
5454
reload(configuration?: IWindowConfiguration, cli?: ParsedArgs): void;
5555

5656
focus(): void;

src/vs/workbench/api/browser/mainThreadExtensionService.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { localize } from 'vs/nls';
1414
import { Action } from 'vs/base/common/actions';
1515
import { IExtensionEnablementService, EnablementState } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
1616
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
17-
import { IWindowService } from 'vs/platform/windows/common/windows';
17+
import { IHostService } from 'vs/workbench/services/host/browser/host';
1818
import { IExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/common/extensions';
1919
import { CancellationToken } from 'vs/base/common/cancellation';
2020
import { ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
@@ -26,21 +26,21 @@ export class MainThreadExtensionService implements MainThreadExtensionServiceSha
2626
private readonly _extensionService: IExtensionService;
2727
private readonly _notificationService: INotificationService;
2828
private readonly _extensionsWorkbenchService: IExtensionsWorkbenchService;
29-
private readonly _windowService: IWindowService;
29+
private readonly _hostService: IHostService;
3030
private readonly _extensionEnablementService: IExtensionEnablementService;
3131

3232
constructor(
3333
extHostContext: IExtHostContext,
3434
@IExtensionService extensionService: IExtensionService,
3535
@INotificationService notificationService: INotificationService,
3636
@IExtensionsWorkbenchService extensionsWorkbenchService: IExtensionsWorkbenchService,
37-
@IWindowService windowService: IWindowService,
37+
@IHostService hostService: IHostService,
3838
@IExtensionEnablementService extensionEnablementService: IExtensionEnablementService
3939
) {
4040
this._extensionService = extensionService;
4141
this._notificationService = notificationService;
4242
this._extensionsWorkbenchService = extensionsWorkbenchService;
43-
this._windowService = windowService;
43+
this._hostService = hostService;
4444
this._extensionEnablementService = extensionEnablementService;
4545
}
4646

@@ -93,7 +93,7 @@ export class MainThreadExtensionService implements MainThreadExtensionServiceSha
9393
severity: Severity.Error,
9494
message: localize('reload window', "Cannot activate the '{0}' extension because it depends on the '{1}' extension, which is not loaded. Would you like to reload the window to load the extension?", extName, missingInstalledDependency.manifest.displayName || missingInstalledDependency.manifest.name),
9595
actions: {
96-
primary: [new Action('reload', localize('reload', "Reload Window"), '', true, () => this._windowService.reloadWindow())]
96+
primary: [new Action('reload', localize('reload', "Reload Window"), '', true, () => this._hostService.reload())]
9797
}
9898
});
9999
} else {
@@ -104,7 +104,7 @@ export class MainThreadExtensionService implements MainThreadExtensionServiceSha
104104
actions: {
105105
primary: [new Action('enable', localize('enable dep', "Enable and Reload"), '', true,
106106
() => this._extensionEnablementService.setEnablement([missingInstalledDependency], enablementState === EnablementState.DisabledGlobally ? EnablementState.EnabledGlobally : EnablementState.EnabledWorkspace)
107-
.then(() => this._windowService.reloadWindow(), e => this._notificationService.error(e)))]
107+
.then(() => this._hostService.reload(), e => this._notificationService.error(e)))]
108108
}
109109
});
110110
}
@@ -120,7 +120,7 @@ export class MainThreadExtensionService implements MainThreadExtensionServiceSha
120120
actions: {
121121
primary: [new Action('install', localize('install missing dep', "Install and Reload"), '', true,
122122
() => this._extensionsWorkbenchService.install(dependencyExtension)
123-
.then(() => this._windowService.reloadWindow(), e => this._notificationService.error(e)))]
123+
.then(() => this._hostService.reload(), e => this._notificationService.error(e)))]
124124
}
125125
});
126126
} else {

src/vs/workbench/api/browser/mainThreadUrls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { extHostNamedCustomer } from '../common/extHostCustomers';
88
import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
99
import { URI, UriComponents } from 'vs/base/common/uri';
1010
import { IDisposable } from 'vs/base/common/lifecycle';
11-
import { IExtensionUrlHandler } from 'vs/workbench/services/extensions/common/extensionUrlHandler';
11+
import { IExtensionUrlHandler } from 'vs/workbench/services/extensions/browser/extensionUrlHandler';
1212
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
1313

1414
class ExtensionUrlHandler implements IURLHandler {

src/vs/workbench/browser/actions/windowActions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ export class ReloadWindowAction extends Action {
213213
constructor(
214214
id: string,
215215
label: string,
216-
@IWindowService private readonly windowService: IWindowService
216+
@IHostService private readonly hostService: IHostService
217217
) {
218218
super(id, label);
219219
}
220220

221221
async run(): Promise<boolean> {
222-
await this.windowService.reloadWindow();
222+
await this.hostService.reload();
223223

224224
return true;
225225
}

0 commit comments

Comments
 (0)