未验证 提交 24036d74 编写于 作者: B Benjamin Pasero 提交者: GitHub

Tweak lifecycle phases (#63899)

* lifecycle - signal READY earlier to allow commands to run

* lifecycle - move READY phase as last thing into shell

* workbench - isCreated() => isRestored()

* lifecycle - tweak phase
上级 bb0242c7
......@@ -466,7 +466,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private registerNavigationListenerOn(command: 'swipe' | 'app-command', back: 'left' | 'browser-backward', forward: 'right' | 'browser-forward', acrossEditors: boolean) {
this._win.on(command as 'swipe' /* | 'app-command' */, (e: Electron.Event, cmd: string) => {
if (this._readyState !== ReadyState.READY) {
if (!this.isReady) {
return; // window must be ready
}
......
......@@ -216,9 +216,9 @@ export class WindowsManager implements IWindowsMainService {
});
});
// React to workbench loaded events from windows
ipc.on('vscode:workbenchLoaded', (event: any, windowId: number) => {
this.logService.trace('IPC#vscode-workbenchLoaded');
// React to workbench ready events from windows
ipc.on('vscode:workbenchReady', (event: any, windowId: number) => {
this.logService.trace('IPC#vscode-workbenchReady');
const win = this.getWindowById(windowId);
if (win) {
......
......@@ -84,17 +84,35 @@ export function StartupKindToString(startupKind: StartupKind): string {
}
export const enum LifecyclePhase {
/**
* The first phase signals that we are about to startup getting ready.
*/
Starting = 1,
Restoring = 2,
Running = 3,
/**
* Services are ready and the view is about to restore its state.
*/
Ready = 2,
/**
* Views, panels and editors have restored. For editors this means, that
* they show their contents fully.
*/
Restored = 3,
/**
* The last phase after views, panels and editors have restored and
* some time has passed (few seconds).
*/
Eventually = 4
}
export function LifecyclePhaseToString(phase: LifecyclePhase) {
switch (phase) {
case LifecyclePhase.Starting: return 'Starting';
case LifecyclePhase.Restoring: return 'Restoring';
case LifecyclePhase.Running: return 'Running';
case LifecyclePhase.Ready: return 'Ready';
case LifecyclePhase.Restored: return 'Restored';
case LifecyclePhase.Eventually: return 'Eventually';
}
}
......@@ -142,7 +160,7 @@ export const NullLifecycleService: ILifecycleService = {
_serviceBrand: null,
onWillShutdown: Event.None,
onShutdown: Event.None,
phase: LifecyclePhase.Running,
phase: LifecyclePhase.Restored,
startupKind: StartupKind.NewWindow,
when() { return Promise.resolve(); }
};
......
......@@ -188,7 +188,7 @@ export class ActivitybarPart extends Part {
// The workaround is to promote the element onto its own drawing layer. We do
// this only after the workbench has loaded because otherwise there is ugly flicker.
if (isMacintosh) {
this.lifecycleService.when(LifecyclePhase.Running).then(() => {
this.lifecycleService.when(LifecyclePhase.Ready).then(() => {
scheduleAtNextAnimationFrame(() => { // another delay...
scheduleAtNextAnimationFrame(() => { // ...to prevent more flickering on startup
registerThemingParticipant((theme, collector) => {
......
......@@ -221,7 +221,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
// Report progress for slow loading composites (but only if we did not create the composites before already)
const progressService = this.mapProgressServiceToComposite[composite.getId()];
if (progressService && !compositeContainer) {
this.mapProgressServiceToComposite[composite.getId()].showWhile(Promise.resolve(), this.partService.isCreated() ? 800 : 3200 /* less ugly initial startup */);
this.mapProgressServiceToComposite[composite.getId()].showWhile(Promise.resolve(), this.partService.isRestored() ? 800 : 3200 /* less ugly initial startup */);
}
// Fill Content and Actions
......
......@@ -168,7 +168,7 @@ export class EditorControl extends Disposable {
// Show progress while setting input after a certain timeout. If the workbench is opening
// be more relaxed about progress showing by increasing the delay a little bit to reduce flicker.
const operation = this.editorOperation.start(this.partService.isCreated() ? 800 : 3200);
const operation = this.editorOperation.start(this.partService.isRestored() ? 800 : 3200);
// Call into editor control
const editorWillChange = !inputMatches;
......
......@@ -82,7 +82,7 @@ export class NotificationsToasts extends Themable {
private registerListeners(): void {
// Wait for the running phase to ensure we can draw notifications properly
this.lifecycleService.when(LifecyclePhase.Running).then(() => {
this.lifecycleService.when(LifecyclePhase.Ready).then(() => {
// Show toast for initial notifications if any
this.model.notifications.forEach(notification => this.addToast(notification));
......
......@@ -96,7 +96,7 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR
private triggerAndDisposeAction(instantiationService: IInstantiationService, lifecycleService: ILifecycleService, descriptor: SyncActionDescriptor, args: any): Thenable<void> {
// run action when workbench is created
return lifecycleService.when(LifecyclePhase.Running).then(() => {
return lifecycleService.when(LifecyclePhase.Ready).then(() => {
const actionInstance = instantiationService.createInstance(descriptor.syncDescriptor);
try {
actionInstance.label = descriptor.label || actionInstance.label;
......
......@@ -69,7 +69,7 @@ class WorkbenchContributionsRegistry implements IWorkbenchContributionsRegistry
this.instantiationService = instantiationService;
this.lifecycleService = lifecycleService;
[LifecyclePhase.Starting, LifecyclePhase.Restoring, LifecyclePhase.Running, LifecyclePhase.Eventually].forEach(phase => {
[LifecyclePhase.Starting, LifecyclePhase.Ready, LifecyclePhase.Restored, LifecyclePhase.Eventually].forEach(phase => {
this.instantiateByPhase(instantiationService, lifecycleService, phase);
});
}
......
......@@ -100,7 +100,6 @@ import { ILabelService, LabelService } from 'vs/platform/label/common/label';
import { IDownloadService } from 'vs/platform/download/common/download';
import { DownloadService } from 'vs/platform/download/node/downloadService';
import { DownloadServiceChannel } from 'vs/platform/download/node/downloadIpc';
import { runWhenIdle } from 'vs/base/common/async';
import { TextResourcePropertiesService } from 'vs/workbench/services/textfile/electron-browser/textResourcePropertiesService';
import { MulitExtensionManagementService } from 'vs/platform/extensionManagement/node/multiExtensionManagement';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
......@@ -189,7 +188,7 @@ export class WorkbenchShell extends Disposable {
this.logService.warn('Workbench did not finish loading in 10 seconds, that might be a problem that should be reported.');
}, 10000);
this.lifecycleService.when(LifecyclePhase.Running).then(() => {
this.lifecycleService.when(LifecyclePhase.Restored).then(() => {
clearTimeout(timeoutHandle);
});
}
......@@ -208,15 +207,9 @@ export class WorkbenchShell extends Disposable {
try {
const workbench = instantiationService.createInstance(Workbench, container, this.configuration, serviceCollection, this.lifecycleService, this.mainProcessClient);
// Set lifecycle phase to `Restoring`
this.lifecycleService.phase = LifecyclePhase.Restoring;
// Startup Workbench
workbench.startup().then(startupInfos => {
// Set lifecycle phase to `Runnning`
this.lifecycleService.phase = LifecyclePhase.Running;
// Startup Telemetry
this.logStartupTelemetry(startupInfos);
......@@ -224,14 +217,6 @@ export class WorkbenchShell extends Disposable {
if (!this.environmentService.extensionTestsPath) {
this.logStorageTelemetry();
}
// Set lifecycle phase to `Runnning For A Bit` after a short delay
let eventuallPhaseTimeoutHandle = runWhenIdle(() => {
eventuallPhaseTimeoutHandle = void 0;
this.lifecycleService.phase = LifecyclePhase.Eventually;
}, 5000);
this._register(eventuallPhaseTimeoutHandle);
}, error => handleStartupError(this.logService, error));
return workbench;
......@@ -546,6 +531,9 @@ export class WorkbenchShell extends Disposable {
// Listeners
this.registerListeners();
// Set lifecycle phase to `Ready`
this.lifecycleService.phase = LifecyclePhase.Ready;
}
private registerListeners(): void {
......
......@@ -176,13 +176,13 @@ export class ElectronWindow extends Themable {
// Fullscreen Events
ipc.on('vscode:enterFullScreen', () => {
this.lifecycleService.when(LifecyclePhase.Running).then(() => {
this.lifecycleService.when(LifecyclePhase.Ready).then(() => {
browser.setFullscreen(true);
});
});
ipc.on('vscode:leaveFullScreen', () => {
this.lifecycleService.when(LifecyclePhase.Running).then(() => {
this.lifecycleService.when(LifecyclePhase.Ready).then(() => {
browser.setFullscreen(false);
});
});
......@@ -191,7 +191,7 @@ export class ElectronWindow extends Themable {
ipc.on('vscode:enterHighContrast', () => {
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
if (windowConfig && windowConfig.autoDetectHighContrast) {
this.lifecycleService.when(LifecyclePhase.Running).then(() => {
this.lifecycleService.when(LifecyclePhase.Ready).then(() => {
this.themeService.setColorTheme(VS_HC_THEME, null);
});
}
......@@ -200,7 +200,7 @@ export class ElectronWindow extends Themable {
ipc.on('vscode:leaveHighContrast', () => {
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
if (windowConfig && windowConfig.autoDetectHighContrast) {
this.lifecycleService.when(LifecyclePhase.Running).then(() => {
this.lifecycleService.when(LifecyclePhase.Ready).then(() => {
this.themeService.restoreColorTheme();
});
}
......@@ -278,16 +278,16 @@ export class ElectronWindow extends Themable {
return null;
};
// Emit event when vscode has loaded
this.lifecycleService.when(LifecyclePhase.Running).then(() => {
ipc.send('vscode:workbenchLoaded', this.windowService.getCurrentWindowId());
// Emit event when vscode is ready
this.lifecycleService.when(LifecyclePhase.Ready).then(() => {
ipc.send('vscode:workbenchReady', this.windowService.getCurrentWindowId());
});
// Integrity warning
this.integrityService.isPure().then(res => this.titleService.updateProperties({ isPure: res.isPure }));
// Root warning
this.lifecycleService.when(LifecyclePhase.Running).then(() => {
this.lifecycleService.when(LifecyclePhase.Ready).then(() => {
let isAdminPromise: Promise<boolean>;
if (isWindows) {
isAdminPromise = import('native-is-elevated').then(isElevated => isElevated());
......@@ -374,7 +374,7 @@ export class ElectronWindow extends Themable {
}
private resolveKeybindings(actionIds: string[]): Promise<{ id: string; label: string, isNative: boolean; }[]> {
return Promise.all([this.lifecycleService.when(LifecyclePhase.Running), this.extensionService.whenInstalledExtensionsRegistered()]).then(() => {
return Promise.all([this.lifecycleService.when(LifecyclePhase.Ready), this.extensionService.whenInstalledExtensionsRegistered()]).then(() => {
return arrays.coalesce(actionIds.map(id => {
const binding = this.keybindingService.lookupKeybinding(id);
if (!binding) {
......@@ -454,7 +454,7 @@ export class ElectronWindow extends Themable {
}
private openResources(resources: (IResourceInput | IUntitledResourceInput)[], diffMode: boolean): Thenable<any> {
return this.lifecycleService.when(LifecyclePhase.Running).then(() => {
return this.lifecycleService.when(LifecyclePhase.Restored).then(() => {
// In diffMode we open 2 resources as diff
if (diffMode && resources.length === 2) {
......
......@@ -9,7 +9,7 @@ import { localize } from 'vs/nls';
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
import { Event, Emitter, once } from 'vs/base/common/event';
import * as DOM from 'vs/base/browser/dom';
import { RunOnceScheduler } from 'vs/base/common/async';
import { RunOnceScheduler, runWhenIdle } from 'vs/base/common/async';
import * as browser from 'vs/base/browser/browser';
import * as perf from 'vs/base/common/performance';
import * as errors from 'vs/base/common/errors';
......@@ -72,7 +72,7 @@ import { ProgressService2 } from 'vs/workbench/services/progress/browser/progres
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle';
import { ShutdownReason, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { LifecycleService } from 'vs/platform/lifecycle/electron-browser/lifecycleService';
import { IWindowService, IWindowConfiguration, IPath, MenuBarVisibility, getTitleBarStyle } from 'vs/platform/windows/common/windows';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
......@@ -188,7 +188,7 @@ export class Workbench extends Disposable implements IPartService {
private workbenchParams: WorkbenchParams;
private workbench: HTMLElement;
private workbenchStarted: boolean;
private workbenchCreated: boolean;
private workbenchRestored: boolean;
private workbenchShutdown: boolean;
private editorService: EditorService;
......@@ -504,9 +504,6 @@ export class Workbench extends Disposable implements IPartService {
}
private onFullscreenChanged(): void {
if (!this.isCreated) {
return; // we need to be ready
}
// Apply as CSS class
const isFullscreen = browser.isFullscreen();
......@@ -772,7 +769,18 @@ export class Workbench extends Disposable implements IPartService {
}
const onRestored = (error?: Error): IWorkbenchStartedInfo => {
this.workbenchCreated = true;
this.workbenchRestored = true;
// Set lifecycle phase to `Restored`
this.lifecycleService.phase = LifecyclePhase.Restored;
// Set lifecycle phase to `Runnning For A Bit` after a short delay
let eventuallPhaseTimeoutHandle = runWhenIdle(() => {
eventuallPhaseTimeoutHandle = void 0;
this.lifecycleService.phase = LifecyclePhase.Eventually;
}, 5000);
this._register(eventuallPhaseTimeoutHandle);
if (error) {
errors.onUnexpectedError(error);
......@@ -1147,8 +1155,8 @@ export class Workbench extends Disposable implements IPartService {
get onEditorLayout(): Event<IDimension> { return this.editorPart.onDidLayout; }
isCreated(): boolean {
return !!(this.workbenchCreated && this.workbenchStarted);
isRestored(): boolean {
return !!(this.workbenchRestored && this.workbenchStarted);
}
hasFocus(part: Parts): boolean {
......
......@@ -25,7 +25,7 @@ export class BackupRestorer implements IWorkbenchContribution {
}
private restoreBackups(): void {
this.lifecycleService.when(LifecyclePhase.Running).then(() => this.doRestoreBackups());
this.lifecycleService.when(LifecyclePhase.Restored).then(() => this.doRestoreBackups());
}
private doRestoreBackups(): Thenable<URI[]> {
......
......@@ -62,7 +62,7 @@ class MultiCursorModifierContextKeyController implements IWorkbenchContribution
}
}
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(MultiCursorModifierContextKeyController, LifecyclePhase.Running);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(MultiCursorModifierContextKeyController, LifecyclePhase.Restored);
const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
......
......@@ -36,6 +36,6 @@ Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescri
));
// Register view location updater
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(CommentPanelVisibilityUpdater, LifecyclePhase.Restoring);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(CommentPanelVisibilityUpdater, LifecyclePhase.Starting);
registerSingleton(ICommentService, CommentService);
......@@ -123,8 +123,8 @@ const registry = Registry.as<IWorkbenchActionRegistry>(WorkbenchActionRegistryEx
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenDebugPanelAction, OpenDebugPanelAction.ID, OpenDebugPanelAction.LABEL, openPanelKb), 'View: Debug Console', nls.localize('view', "View"));
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenDebugViewletAction, OpenDebugViewletAction.ID, OpenDebugViewletAction.LABEL, openViewletKb), 'View: Show Debug', nls.localize('view', "View"));
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DebugEditorModelManager, LifecyclePhase.Running);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DebugToolbar, LifecyclePhase.Running);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DebugEditorModelManager, LifecyclePhase.Restored);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DebugToolbar, LifecyclePhase.Restored);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DebugContentProvider, LifecyclePhase.Eventually);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(StatusBarColorProvider, LifecyclePhase.Eventually);
......
......@@ -53,10 +53,10 @@ registerSingleton(IExtensionTipsService, ExtensionTipsService);
registerSingleton(IExtensionHostProfileService, ExtensionHostProfileService);
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(StatusUpdater, LifecyclePhase.Running);
workbenchRegistry.registerWorkbenchContribution(StatusUpdater, LifecyclePhase.Restored);
workbenchRegistry.registerWorkbenchContribution(MaliciousExtensionChecker, LifecyclePhase.Eventually);
workbenchRegistry.registerWorkbenchContribution(ConfigureRecommendedExtensionsCommandsContributor, LifecyclePhase.Eventually);
workbenchRegistry.registerWorkbenchContribution(KeymapExtensions, LifecyclePhase.Running);
workbenchRegistry.registerWorkbenchContribution(KeymapExtensions, LifecyclePhase.Restored);
workbenchRegistry.registerWorkbenchContribution(ExtensionsViewletViewsContribution, LifecyclePhase.Starting);
workbenchRegistry.registerWorkbenchContribution(ExtensionActivationProgress, LifecyclePhase.Eventually);
workbenchRegistry.registerWorkbenchContribution(ExtensionsAutoProfiler, LifecyclePhase.Eventually);
......
......@@ -350,8 +350,8 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
return;
}
// Return now if the workbench has not yet been created - in this case the workbench takes care of restoring last used editors
if (!this.partService.isCreated()) {
// Return now if the workbench has not yet been restored - in this case the workbench takes care of restoring last used editors
if (!this.partService.isRestored()) {
return;
}
......@@ -795,7 +795,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
this.decorationProvider.changed(targetsToResolve.map(t => t.root.resource));
return result;
});
this.progressService.showWhile(promise, this.partService.isCreated() ? 800 : 1200 /* less ugly initial startup */);
this.progressService.showWhile(promise, this.partService.isRestored() ? 800 : 1200 /* less ugly initial startup */);
return promise;
}
......
......@@ -115,7 +115,7 @@ export class FileDataSource implements IDataSource {
return []; // we could not resolve any children because of an error
});
this.progressService.showWhile(promise, this.partService.isCreated() ? 800 : 3200 /* less ugly initial startup */);
this.progressService.showWhile(promise, this.partService.isRestored() ? 800 : 3200 /* less ugly initial startup */);
return promise;
}
......
......@@ -81,7 +81,7 @@ Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescri
// workbench
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(ActivityUpdater, LifecyclePhase.Running);
workbenchRegistry.registerWorkbenchContribution(ActivityUpdater, LifecyclePhase.Restored);
// actions
const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
......
......@@ -92,7 +92,7 @@ class MarkersFileDecorations implements IWorkbenchContribution {
}
}
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(MarkersFileDecorations, LifecyclePhase.Running);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(MarkersFileDecorations, LifecyclePhase.Restored);
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).registerConfiguration({
'id': 'problems',
......
......@@ -75,7 +75,7 @@ class OutputContribution implements IWorkbenchContribution {
}
}
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(OutputContribution, LifecyclePhase.Running);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(OutputContribution, LifecyclePhase.Restored);
// register toggle output action globally
const actionRegistry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
......
......@@ -104,4 +104,4 @@ class StartupProfiler implements IWorkbenchContribution {
}
const registry = Registry.as<IWorkbenchContributionsRegistry>(Extensions.Workbench);
registry.registerWorkbenchContribution(StartupProfiler, LifecyclePhase.Running);
registry.registerWorkbenchContribution(StartupProfiler, LifecyclePhase.Restored);
......@@ -215,4 +215,4 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
}
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(SettingsChangeRelauncher, LifecyclePhase.Running);
workbenchRegistry.registerWorkbenchContribution(SettingsChangeRelauncher, LifecyclePhase.Restored);
......@@ -35,7 +35,7 @@ class OpenSCMViewletAction extends ShowViewletAction {
}
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(DirtyDiffWorkbenchController, LifecyclePhase.Running);
.registerWorkbenchContribution(DirtyDiffWorkbenchController, LifecyclePhase.Restored);
const viewletDescriptor = new ViewletDescriptor(
SCMViewlet,
......@@ -49,10 +49,10 @@ Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets)
.registerViewlet(viewletDescriptor);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(StatusUpdater, LifecyclePhase.Running);
.registerWorkbenchContribution(StatusUpdater, LifecyclePhase.Restored);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(StatusBarController, LifecyclePhase.Running);
.registerWorkbenchContribution(StatusBarController, LifecyclePhase.Restored);
// Register Action to Open Viewlet
Registry.as<IWorkbenchActionRegistry>(WorkbenchActionExtensions.WorkbenchActions).registerWorkbenchAction(
......
......@@ -464,7 +464,7 @@ Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescri
));
// Register view location updater
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(SearchViewLocationUpdater, LifecyclePhase.Restoring);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(SearchViewLocationUpdater, LifecyclePhase.Starting);
// Actions
const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
......
......@@ -142,7 +142,7 @@ class SnippetsService implements ISnippetsService {
@IFileService private readonly _fileService: IFileService,
@ILifecycleService lifecycleService: ILifecycleService,
) {
this._pendingWork.push(Promise.resolve(lifecycleService.when(LifecyclePhase.Running).then(() => {
this._pendingWork.push(Promise.resolve(lifecycleService.when(LifecyclePhase.Restored).then(() => {
this._initExtensionSnippets();
this._initUserSnippets();
this._initWorkspaceSnippets();
......
......@@ -37,7 +37,7 @@ class PartsSplash {
@ILifecycleService lifecycleService: ILifecycleService,
@IBroadcastService private broadcastService: IBroadcastService
) {
lifecycleService.when(LifecyclePhase.Running).then(_ => this._removePartsSplash());
lifecycleService.when(LifecyclePhase.Restored).then(_ => this._removePartsSplash());
debounceEvent(anyEvent<any>(
onDidChangeFullscreen,
_partService.onEditorLayout
......
......@@ -135,5 +135,5 @@ class LanguageSurveysContribution implements IWorkbenchContribution {
if (language === 'en' && product.surveys && product.surveys.length) {
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(LanguageSurveysContribution, LifecyclePhase.Running);
workbenchRegistry.registerWorkbenchContribution(LanguageSurveysContribution, LifecyclePhase.Ready);
}
......@@ -87,5 +87,5 @@ class NPSContribution implements IWorkbenchContribution {
if (language === 'en' && product.npsSurveyUrl) {
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(NPSContribution, LifecyclePhase.Running);
workbenchRegistry.registerWorkbenchContribution(NPSContribution, LifecyclePhase.Ready);
}
\ No newline at end of file
......@@ -16,11 +16,11 @@ import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
const workbench = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
workbench.registerWorkbenchContribution(ProductContribution, LifecyclePhase.Running);
workbench.registerWorkbenchContribution(ProductContribution, LifecyclePhase.Restored);
if (platform.isWindows) {
if (process.arch === 'ia32') {
workbench.registerWorkbenchContribution(Win3264BitContribution, LifecyclePhase.Running);
workbench.registerWorkbenchContribution(Win3264BitContribution, LifecyclePhase.Restored);
}
}
......
......@@ -200,7 +200,7 @@ export class WatermarkContribution implements IWorkbenchContribution {
}
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(WatermarkContribution, LifecyclePhase.Running);
.registerWorkbenchContribution(WatermarkContribution, LifecyclePhase.Restored);
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
.registerConfiguration({
......
......@@ -11,7 +11,7 @@ import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
Registry
.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(GettingStarted, LifecyclePhase.Running);
.registerWorkbenchContribution(GettingStarted, LifecyclePhase.Restored);
Registry
.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
......
......@@ -37,7 +37,7 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
});
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(WelcomePageContribution, LifecyclePhase.Running);
.registerWorkbenchContribution(WelcomePageContribution, LifecyclePhase.Restored);
Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions)
.registerWorkbenchAction(new SyncActionDescriptor(WelcomePageAction, WelcomePageAction.ID, WelcomePageAction.LABEL), 'Help: Welcome', localize('help', "Help"));
......
......@@ -103,12 +103,12 @@ export class ExtensionService extends Disposable implements IExtensionService {
private _startDelayed(lifecycleService: ILifecycleService): void {
// delay extension host creation and extension scanning
// until the workbench is restoring. we cannot defer the
// extension host more (LifecyclePhase.Running) because
// until the workbench is running. we cannot defer the
// extension host more (LifecyclePhase.Restored) because
// some editors require the extension host to restore
// and this would result in a deadlock
// see https://github.com/Microsoft/vscode/issues/41322
lifecycleService.when(LifecyclePhase.Restoring).then(() => {
lifecycleService.when(LifecyclePhase.Ready).then(() => {
// reschedule to ensure this runs after restoring viewlets, panels, and editors
runWhenIdle(() => {
perf.mark('willLoadExtensions');
......
......@@ -105,13 +105,13 @@ export class FileService extends Disposable implements IFileService {
private registerListeners(): void {
// Wait until we are fully running before starting file watchers
this.lifecycleService.when(LifecyclePhase.Running).then(() => {
this.lifecycleService.when(LifecyclePhase.Restored).then(() => {
this.setupFileWatching();
});
// Workbench State Change
this._register(this.contextService.onDidChangeWorkbenchState(() => {
if (this.lifecycleService.phase >= LifecyclePhase.Running) {
if (this.lifecycleService.phase >= LifecyclePhase.Restored) {
this.setupFileWatching();
}
}));
......
......@@ -718,8 +718,8 @@ export class HistoryService extends Disposable implements IHistoryService {
return false;
}
if (this.partService.isCreated() && !this.fileService.canHandleResource(inputResource)) {
return false; // make sure to only check this when workbench has started (for https://github.com/Microsoft/vscode/issues/48275)
if (this.partService.isRestored() && !this.fileService.canHandleResource(inputResource)) {
return false; // make sure to only check this when workbench has restored (for https://github.com/Microsoft/vscode/issues/48275)
}
return inputResource.toString() === resource.toString();
......
......@@ -56,9 +56,10 @@ export interface IPartService {
onEditorLayout: Event<IDimension>;
/**
* Asks the part service to if all parts have been created.
* Asks the part service if all parts have been fully restored. For editor part
* this means that the contents of editors have loaded.
*/
isCreated(): boolean;
isRestored(): boolean;
/**
* Returns whether the given part has the keyboard focus or not.
......
......@@ -449,7 +449,7 @@ export class TestPartService implements IPartService {
return this._onEditorLayout.event;
}
public isCreated(): boolean {
public isRestored(): boolean {
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册