Skip to content

Commit fa592ef

Browse files
author
Benjamin Pasero
committed
introduce and use LifecyclePhase.RunningForABit (for microsoft#38080)
1 parent 8692ecf commit fa592ef

4 files changed

Lines changed: 30 additions & 12 deletions

File tree

src/vs/platform/lifecycle/common/lifecycle.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ export enum LifecyclePhase {
4949
Starting = 1,
5050
Restoring = 2,
5151
Running = 3,
52-
ShuttingDown = 4
52+
RunningForABit = 4,
53+
ShuttingDown = 5
5354
}
5455

5556
/**

src/vs/workbench/common/contributions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class WorkbenchContributionsRegistry implements IWorkbenchContributionsRe
7272
this.instantiationService = instantiationService;
7373
this.lifecycleService = lifecycleService;
7474

75-
[LifecyclePhase.Starting, LifecyclePhase.Restoring, LifecyclePhase.Running, LifecyclePhase.ShuttingDown].forEach(phase => {
75+
[LifecyclePhase.Starting, LifecyclePhase.Restoring, LifecyclePhase.Running, LifecyclePhase.RunningForABit, LifecyclePhase.ShuttingDown].forEach(phase => {
7676
this.instantiateByPhase(instantiationService, lifecycleService, phase);
7777
});
7878
}

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,32 @@ export class WorkbenchShell {
191191

192192
private onWorkbenchStarted(info: IWorkbenchStartedInfo, instantiationService: IInstantiationService): void {
193193

194-
// Telemetry: workspace info
194+
// Startup Telemetry
195+
this.logStartupTelemetry(info);
196+
197+
// Root Warning
198+
if ((platform.isLinux || platform.isMacintosh) && process.getuid() === 0) {
199+
this.messageService.show(Severity.Warning, nls.localize('runningAsRoot', "It is recommended not to run Code as 'root'."));
200+
}
201+
202+
// Set lifecycle phase to `Runnning` so that other contributions can now do something
203+
this.lifecycleService.phase = LifecyclePhase.Running;
204+
205+
// Set lifecycle phase to `Runnning For A Bit` after a short delay
206+
let timeoutHandle = setTimeout(() => {
207+
timeoutHandle = void 0;
208+
this.lifecycleService.phase = LifecyclePhase.RunningForABit;
209+
}, 3000);
210+
this.toUnbind.push({
211+
dispose: () => {
212+
if (timeoutHandle) {
213+
clearTimeout(timeoutHandle);
214+
}
215+
}
216+
});
217+
}
218+
219+
private logStartupTelemetry(info: IWorkbenchStartedInfo): void {
195220
const { filesToOpen, filesToCreate, filesToDiff } = this.configuration;
196221
/* __GDPR__
197222
"workspaceLoad" : {
@@ -246,14 +271,6 @@ export class WorkbenchShell {
246271
*/
247272
this.telemetryService.publicLog('startupTime', this.timerService.startupMetrics);
248273
});
249-
250-
// Root Warning
251-
if ((platform.isLinux || platform.isMacintosh) && process.getuid() === 0) {
252-
this.messageService.show(Severity.Warning, nls.localize('runningAsRoot', "It is recommended not to run Code as 'root'."));
253-
}
254-
255-
// Set lifecycle phase to `Runnning` so that other contributions can now do something
256-
this.lifecycleService.phase = LifecyclePhase.Running;
257274
}
258275

259276
private initServiceCollection(container: HTMLElement): [IInstantiationService, ServiceCollection] {

src/vs/workbench/parts/stats/node/stats.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ import { WorkspaceStats } from 'vs/workbench/parts/stats/node/workspaceStats';
1111
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
1212

1313
// Register Workspace Stats Contribution
14-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceStats, LifecyclePhase.Running);
14+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceStats, LifecyclePhase.RunningForABit);

0 commit comments

Comments
 (0)