mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-13 15:35:20 +01:00
limit view ids globally
This commit is contained in:
@@ -375,16 +375,15 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
|
||||
collector.warn(localize('ViewContainerDoesnotExist', "View container '{0}' does not exist and all views registered to it will be added to 'Explorer'.", entry.key));
|
||||
}
|
||||
const container = viewContainer || this.getDefaultViewContainer();
|
||||
const registeredViews = this.viewsRegistry.getViews(container);
|
||||
const viewIds: string[] = [];
|
||||
const viewDescriptors = coalesce(entry.value.map((item, index) => {
|
||||
// validate
|
||||
if (viewIds.indexOf(item.id) !== -1) {
|
||||
collector.error(localize('duplicateView1', "Cannot register multiple views with same id `{0}` in the view container `{1}`", item.id, container.id));
|
||||
collector.error(localize('duplicateView1', "Cannot register multiple views with same id `{0}`", item.id));
|
||||
return null;
|
||||
}
|
||||
if (registeredViews.some(v => v.id === item.id)) {
|
||||
collector.error(localize('duplicateView2', "A view with id `{0}` is already registered in the view container `{1}`", item.id, container.id));
|
||||
if (this.viewsRegistry.getView(item.id) !== null) {
|
||||
collector.error(localize('duplicateView2', "A view with id `{0}` is already registered.", item.id));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -336,8 +336,8 @@ class ViewsRegistry extends Disposable implements IViewsRegistry {
|
||||
this._viewContainers.push(viewContainer);
|
||||
}
|
||||
for (const viewDescriptor of viewDescriptors) {
|
||||
if (views.some(v => v.id === viewDescriptor.id)) {
|
||||
throw new Error(localize('duplicateId', "A view with id '{0}' is already registered in the container '{1}'", viewDescriptor.id, viewContainer.id));
|
||||
if (this.getView(viewDescriptor.id) !== null) {
|
||||
throw new Error(localize('duplicateId', "A view with id '{0}' is already registered", viewDescriptor.id));
|
||||
}
|
||||
views.push(viewDescriptor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user