提交 fa592ef4 编写于 作者: B Benjamin Pasero

introduce and use LifecyclePhase.RunningForABit (for #38080)

上级 8692ecf9
......@@ -49,7 +49,8 @@ export enum LifecyclePhase {
Starting = 1,
Restoring = 2,
Running = 3,
ShuttingDown = 4
RunningForABit = 4,
ShuttingDown = 5
}
/**
......
......@@ -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);
});
}
......
......@@ -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] {
......
......@@ -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<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceStats, LifecyclePhase.Running);
\ No newline at end of file
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceStats, LifecyclePhase.RunningForABit);
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册