mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-06 14:24:04 -05:00
introduce and use LifecyclePhase.RunningForABit (for #38080)
This commit is contained in:
@@ -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);
|
||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceStats, LifecyclePhase.RunningForABit);
|
||||
Reference in New Issue
Block a user