From fa592ef424a374edba7b58d49e8b7c69ff8114bc Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 13 Nov 2017 19:51:50 +0100 Subject: [PATCH] introduce and use LifecyclePhase.RunningForABit (for #38080) --- src/vs/platform/lifecycle/common/lifecycle.ts | 3 +- src/vs/workbench/common/contributions.ts | 2 +- src/vs/workbench/electron-browser/shell.ts | 35 ++++++++++++++----- .../parts/stats/node/stats.contribution.ts | 2 +- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/vs/platform/lifecycle/common/lifecycle.ts b/src/vs/platform/lifecycle/common/lifecycle.ts index 3f2cd9cde69..2e96135e9b6 100644 --- a/src/vs/platform/lifecycle/common/lifecycle.ts +++ b/src/vs/platform/lifecycle/common/lifecycle.ts @@ -49,7 +49,8 @@ export enum LifecyclePhase { Starting = 1, Restoring = 2, Running = 3, - ShuttingDown = 4 + RunningForABit = 4, + ShuttingDown = 5 } /** diff --git a/src/vs/workbench/common/contributions.ts b/src/vs/workbench/common/contributions.ts index 23ca3ad3cb2..e826e157282 100644 --- a/src/vs/workbench/common/contributions.ts +++ b/src/vs/workbench/common/contributions.ts @@ -72,7 +72,7 @@ export class WorkbenchContributionsRegistry implements IWorkbenchContributionsRe this.instantiationService = instantiationService; this.lifecycleService = lifecycleService; - [LifecyclePhase.Starting, LifecyclePhase.Restoring, LifecyclePhase.Running, LifecyclePhase.ShuttingDown].forEach(phase => { + [LifecyclePhase.Starting, LifecyclePhase.Restoring, LifecyclePhase.Running, LifecyclePhase.RunningForABit, LifecyclePhase.ShuttingDown].forEach(phase => { this.instantiateByPhase(instantiationService, lifecycleService, phase); }); } diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index ee48fc9392b..215dfaf1822 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -191,7 +191,32 @@ export class WorkbenchShell { private onWorkbenchStarted(info: IWorkbenchStartedInfo, instantiationService: IInstantiationService): void { - // Telemetry: workspace info + // Startup Telemetry + this.logStartupTelemetry(info); + + // Root Warning + if ((platform.isLinux || platform.isMacintosh) && process.getuid() === 0) { + this.messageService.show(Severity.Warning, nls.localize('runningAsRoot', "It is recommended not to run Code as 'root'.")); + } + + // Set lifecycle phase to `Runnning` so that other contributions can now do something + this.lifecycleService.phase = LifecyclePhase.Running; + + // Set lifecycle phase to `Runnning For A Bit` after a short delay + let timeoutHandle = setTimeout(() => { + timeoutHandle = void 0; + this.lifecycleService.phase = LifecyclePhase.RunningForABit; + }, 3000); + this.toUnbind.push({ + dispose: () => { + if (timeoutHandle) { + clearTimeout(timeoutHandle); + } + } + }); + } + + private logStartupTelemetry(info: IWorkbenchStartedInfo): void { const { filesToOpen, filesToCreate, filesToDiff } = this.configuration; /* __GDPR__ "workspaceLoad" : { @@ -246,14 +271,6 @@ export class WorkbenchShell { */ this.telemetryService.publicLog('startupTime', this.timerService.startupMetrics); }); - - // Root Warning - if ((platform.isLinux || platform.isMacintosh) && process.getuid() === 0) { - this.messageService.show(Severity.Warning, nls.localize('runningAsRoot', "It is recommended not to run Code as 'root'.")); - } - - // Set lifecycle phase to `Runnning` so that other contributions can now do something - this.lifecycleService.phase = LifecyclePhase.Running; } private initServiceCollection(container: HTMLElement): [IInstantiationService, ServiceCollection] { diff --git a/src/vs/workbench/parts/stats/node/stats.contribution.ts b/src/vs/workbench/parts/stats/node/stats.contribution.ts index 7b38d263cb9..1703314f940 100644 --- a/src/vs/workbench/parts/stats/node/stats.contribution.ts +++ b/src/vs/workbench/parts/stats/node/stats.contribution.ts @@ -11,4 +11,4 @@ import { WorkspaceStats } from 'vs/workbench/parts/stats/node/workspaceStats'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; // Register Workspace Stats Contribution -Registry.as(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceStats, LifecyclePhase.Running); \ No newline at end of file +Registry.as(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceStats, LifecyclePhase.RunningForABit); \ No newline at end of file -- GitLab