提交 b72c840b 编写于 作者: E Eric Amodio

Fixes #109136

上级 ce9ed29d
...@@ -43,7 +43,7 @@ import { WINDOW_ACTIVE_BORDER, WINDOW_INACTIVE_BORDER } from 'vs/workbench/commo ...@@ -43,7 +43,7 @@ import { WINDOW_ACTIVE_BORDER, WINDOW_INACTIVE_BORDER } from 'vs/workbench/commo
import { LineNumbersType } from 'vs/editor/common/config/editorOptions'; import { LineNumbersType } from 'vs/editor/common/config/editorOptions';
import { ActivitybarPart } from 'vs/workbench/browser/parts/activitybar/activitybarPart'; import { ActivitybarPart } from 'vs/workbench/browser/parts/activitybar/activitybarPart';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { IViewDescriptorService, ViewContainerLocation, IViewsService } from 'vs/workbench/common/views'; import { IViewDescriptorService, ViewContainerLocation } from 'vs/workbench/common/views';
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import { mark } from 'vs/base/common/performance'; import { mark } from 'vs/base/common/performance';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
...@@ -178,7 +178,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi ...@@ -178,7 +178,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
private titleService!: ITitleService; private titleService!: ITitleService;
private viewletService!: IViewletService; private viewletService!: IViewletService;
private viewDescriptorService!: IViewDescriptorService; private viewDescriptorService!: IViewDescriptorService;
private viewsService!: IViewsService;
private contextService!: IWorkspaceContextService; private contextService!: IWorkspaceContextService;
private backupFileService!: IBackupFileService; private backupFileService!: IBackupFileService;
private notificationService!: INotificationService; private notificationService!: INotificationService;
...@@ -273,7 +272,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi ...@@ -273,7 +272,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.panelService = accessor.get(IPanelService); this.panelService = accessor.get(IPanelService);
this.viewletService = accessor.get(IViewletService); this.viewletService = accessor.get(IViewletService);
this.viewDescriptorService = accessor.get(IViewDescriptorService); this.viewDescriptorService = accessor.get(IViewDescriptorService);
this.viewsService = accessor.get(IViewsService);
this.titleService = accessor.get(ITitleService); this.titleService = accessor.get(ITitleService);
this.notificationService = accessor.get(INotificationService); this.notificationService = accessor.get(INotificationService);
this.activityBarService = accessor.get(IActivityBarService); this.activityBarService = accessor.get(IActivityBarService);
...@@ -851,52 +849,60 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi ...@@ -851,52 +849,60 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
if (this.state.views.defaults?.length) { if (this.state.views.defaults?.length) {
mark('willOpenDefaultViews'); mark('willOpenDefaultViews');
const defaultViews = [...this.state.views.defaults]; let locationsRestored: { id: string; order: number }[] = [];
let locationsRestored: boolean[] = []; const tryOpenView = (view: { id: string; order: number }): boolean => {
const location = this.viewDescriptorService.getViewLocationById(view.id);
const tryOpenView = async (viewId: string, index: number) => { if (location !== null) {
const location = this.viewDescriptorService.getViewLocationById(viewId); const container = this.viewDescriptorService.getViewContainerByViewId(view.id);
if (location) { if (container) {
if (view.order >= (locationsRestored?.[location]?.order ?? 0)) {
locationsRestored[location] = { id: container.id, order: view.order };
}
// If the view is in the same location that has already been restored, remove it and continue const containerModel = this.viewDescriptorService.getViewContainerModel(container);
if (locationsRestored[location]) { containerModel.setCollapsed(view.id, false);
defaultViews.splice(index, 1); containerModel.setVisible(view.id, true);
return; return true;
}
const view = await this.viewsService.openView(viewId);
if (view) {
locationsRestored[location] = true;
defaultViews.splice(index, 1);
} }
} }
return false;
}; };
let i = -1; const defaultViews = [...this.state.views.defaults].reverse().map((v, index) => ({ id: v, order: index }));
for (const viewId of defaultViews) {
await tryOpenView(viewId, ++i); let i = defaultViews.length;
while (i) {
i--;
if (tryOpenView(defaultViews[i])) {
defaultViews.splice(i, 1);
}
} }
// If we still have views left over, wait until all extensions have been registered and try again // If we still have views left over, wait until all extensions have been registered and try again
if (defaultViews.length) { if (defaultViews.length) {
await this.extensionService.whenInstalledExtensionsRegistered(); await this.extensionService.whenInstalledExtensionsRegistered();
let i = -1;
for (const viewId of defaultViews) { let i = defaultViews.length;
await tryOpenView(viewId, ++i); while (i) {
i--;
if (tryOpenView(defaultViews[i])) {
defaultViews.splice(i, 1);
}
} }
} }
// If we opened a view in the sidebar, stop any restore there // If we opened a view in the sidebar, stop any restore there
if (locationsRestored[ViewContainerLocation.Sidebar]) { if (locationsRestored[ViewContainerLocation.Sidebar]) {
this.state.sideBar.viewletToRestore = undefined; this.state.sideBar.viewletToRestore = locationsRestored[ViewContainerLocation.Sidebar].id;
} }
// If we opened a view in the panel, stop any restore there // If we opened a view in the panel, stop any restore there
if (locationsRestored[ViewContainerLocation.Panel]) { if (locationsRestored[ViewContainerLocation.Panel]) {
this.state.panel.panelToRestore = undefined; this.state.panel.panelToRestore = locationsRestored[ViewContainerLocation.Panel].id;
} }
mark('didOpenDefaultViews'); mark('didOpenDefaultViews');
......
...@@ -326,7 +326,7 @@ export class ViewsService extends Disposable implements IViewsService { ...@@ -326,7 +326,7 @@ export class ViewsService extends Disposable implements IViewsService {
return null; return null;
} }
async openView<T extends IView>(id: string, focus: boolean): Promise<T | null> { async openView<T extends IView>(id: string, focus?: boolean): Promise<T | null> {
const viewContainer = this.viewDescriptorService.getViewContainerByViewId(id); const viewContainer = this.viewDescriptorService.getViewContainerByViewId(id);
if (!viewContainer) { if (!viewContainer) {
return null; return null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册