Skip to content

Commit 8e97fef

Browse files
author
Benjamin Pasero
committed
cleanup workbench startup
1 parent 90fec34 commit 8e97fef

2 files changed

Lines changed: 13 additions & 28 deletions

File tree

src/vs/workbench/electron-browser/shell.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ export class WorkbenchShell {
166166
// Workbench
167167
this.workbench = instantiationService.createInstance(Workbench, parent.getHTMLElement(), workbenchContainer.getHTMLElement(), this.configuration, serviceCollection, this.lifecycleService);
168168
try {
169-
this.workbench.startup({
170-
onWorkbenchStarted: (info: IWorkbenchStartedInfo) => this.onWorkbenchStarted(info, instantiationService)
171-
});
169+
this.workbench.startup().done(startupInfos => this.onWorkbenchStarted(startupInfos, instantiationService));
172170
} catch (error) {
173171

174172
// Print out error

src/vs/workbench/electron-browser/workbench.ts

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ export interface IWorkbenchStartedInfo {
125125
restoredEditors: string[];
126126
}
127127

128-
export interface IWorkbenchCallbacks {
129-
onServicesCreated?: () => void;
130-
onWorkbenchStarted?: (info: IWorkbenchStartedInfo) => void;
131-
}
132-
133128
const Identifiers = {
134129
WORKBENCH_CONTAINER: 'workbench.main.container',
135130
TITLEBAR_PART: 'workbench.parts.titlebar',
@@ -187,7 +182,6 @@ export class Workbench implements IPartService {
187182
private workbenchLayout: WorkbenchLayout;
188183
private toDispose: IDisposable[];
189184
private toShutdown: { shutdown: () => void; }[];
190-
private callbacks: IWorkbenchCallbacks;
191185
private sideBarHidden: boolean;
192186
private statusBarHidden: boolean;
193187
private activityBarHidden: boolean;
@@ -259,21 +253,17 @@ export class Workbench implements IPartService {
259253
* Starts the workbench and creates the HTML elements on the container. A workbench can only be started
260254
* once. Use the shutdown function to free up resources created by the workbench on startup.
261255
*/
262-
public startup(callbacks?: IWorkbenchCallbacks): void {
256+
public startup(): TPromise<IWorkbenchStartedInfo> {
263257
this.workbenchStarted = true;
264-
this.callbacks = callbacks;
265258

266-
// Create Workbench
259+
// Create Workbench Container
267260
this.createWorkbench();
268261

269262
// Install some global actions
270263
this.createGlobalActions();
271264

272265
// Services
273266
this.initServices();
274-
if (this.callbacks && this.callbacks.onServicesCreated) {
275-
this.callbacks.onServicesCreated();
276-
}
277267

278268
// Contexts
279269
this.messagesVisibleContext = MessagesVisibleContext.bindTo(this.contextKeyService);
@@ -294,13 +284,15 @@ export class Workbench implements IPartService {
294284
this.createWorkbenchLayout();
295285

296286
// Restore Parts
297-
this.restoreParts().done(startedInfo => {
298-
this.workbenchCreated = true;
287+
return this.restoreParts();
288+
}
299289

300-
if (this.callbacks && this.callbacks.onWorkbenchStarted) {
301-
this.callbacks.onWorkbenchStarted(startedInfo);
302-
}
303-
});
290+
private createWorkbench(): void {
291+
this.workbenchContainer = $('.monaco-workbench-container');
292+
this.workbench = $().div({
293+
'class': `monaco-workbench ${isWindows ? 'windows' : isLinux ? 'linux' : 'mac'}`,
294+
id: Identifiers.WORKBENCH_CONTAINER
295+
}).appendTo(this.workbenchContainer);
304296
}
305297

306298
private restoreParts(): TPromise<IWorkbenchStartedInfo> {
@@ -375,6 +367,8 @@ export class Workbench implements IPartService {
375367
}
376368

377369
const onRestored = (error?: Error): IWorkbenchStartedInfo => {
370+
this.workbenchCreated = true;
371+
378372
if (error) {
379373
errors.onUnexpectedError(error);
380374
}
@@ -1138,13 +1132,6 @@ export class Workbench implements IPartService {
11381132
this.toDispose.push(this.workbenchLayout);
11391133
}
11401134

1141-
private createWorkbench(): void {
1142-
1143-
// Create Workbench DIV Off-DOM
1144-
this.workbenchContainer = $('.monaco-workbench-container');
1145-
this.workbench = $().div({ 'class': 'monaco-workbench ' + (isWindows ? 'windows' : isLinux ? 'linux' : 'mac'), id: Identifiers.WORKBENCH_CONTAINER }).appendTo(this.workbenchContainer);
1146-
}
1147-
11481135
private renderWorkbench(): void {
11491136

11501137
// Apply sidebar state as CSS class

0 commit comments

Comments
 (0)