Skip to content

Commit a7bc93f

Browse files
committed
Remove overload for registerEditor
The non-array version of `registerEditor` was only being used in tests
1 parent 6eab67e commit a7bc93f

4 files changed

Lines changed: 9 additions & 16 deletions

File tree

src/vs/workbench/browser/editor.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
88
import { Registry } from 'vs/platform/registry/common/platform';
99
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
1010
import { IConstructorSignature0, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
11-
import { asArray } from 'vs/base/common/arrays';
1211

1312
export interface IEditorDescriptor {
1413
instantiate(instantiationService: IInstantiationService): BaseEditor;
@@ -27,11 +26,10 @@ export interface IEditorRegistry {
2726
* input, the input itself will be asked which editor it prefers if this method is provided. Otherwise
2827
* the first editor in the list will be returned.
2928
*
30-
* @param editorInputDescriptor a constructor function that returns an instance of EditorInput for which the
29+
* @param inputDescriptors A set of constructor functions that returns an instance of EditorInput for which the
3130
* registered editor should be used for.
3231
*/
33-
registerEditor(descriptor: IEditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput>): void;
34-
registerEditor(descriptor: IEditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput>[]): void;
32+
registerEditor(descriptor: IEditorDescriptor, inputDescriptors: readonly SyncDescriptor<EditorInput>[]): void;
3533

3634
/**
3735
* Returns the editor descriptor for the given input or `undefined` if none.
@@ -83,12 +81,7 @@ class EditorRegistry implements IEditorRegistry {
8381
private editors: EditorDescriptor[] = [];
8482
private readonly mapEditorToInputs = new Map<EditorDescriptor, readonly SyncDescriptor<EditorInput>[]>();
8583

86-
registerEditor(descriptor: EditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput>): void;
87-
registerEditor(descriptor: EditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput>[]): void;
88-
registerEditor(descriptor: EditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput> | SyncDescriptor<EditorInput>[]): void {
89-
90-
const inputDescriptors: SyncDescriptor<EditorInput>[] = asArray(editorInputDescriptor);
91-
84+
registerEditor(descriptor: EditorDescriptor, inputDescriptors: readonly SyncDescriptor<EditorInput>[]): void {
9285
// Register (Support multiple Editors per Input)
9386
this.mapEditorToInputs.set(descriptor, inputDescriptors);
9487

src/vs/workbench/services/editor/test/browser/editorGroupsService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ suite('EditorGroupsService', () => {
8080
}
8181

8282
(Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories)).registerEditorInputFactory('testEditorInputForGroupsService', TestEditorInputFactory);
83-
(Registry.as<IEditorRegistry>(Extensions.Editors)).registerEditor(new EditorDescriptor(TestEditorControl, 'MyTestEditorForGroupsService', 'My Test File Editor'), new SyncDescriptor(TestEditorInput));
83+
(Registry.as<IEditorRegistry>(Extensions.Editors)).registerEditor(new EditorDescriptor(TestEditorControl, 'MyTestEditorForGroupsService', 'My Test File Editor'), [new SyncDescriptor(TestEditorInput)]);
8484
}
8585

8686
registerTestEditorInput();

src/vs/workbench/services/editor/test/browser/editorService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class FileServiceProvider extends Disposable {
8383
suite('EditorService', () => {
8484

8585
function registerTestEditorInput(): void {
86-
Registry.as<IEditorRegistry>(Extensions.Editors).registerEditor(new EditorDescriptor(TestEditorControl, 'MyTestEditorForEditorService', 'My Test Editor For Next Editor Service'), new SyncDescriptor(TestEditorInput));
86+
Registry.as<IEditorRegistry>(Extensions.Editors).registerEditor(new EditorDescriptor(TestEditorControl, 'MyTestEditorForEditorService', 'My Test Editor For Next Editor Service'), [new SyncDescriptor(TestEditorInput)]);
8787
}
8888

8989
registerTestEditorInput();

src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ suite('Workbench base editor', () => {
127127
let oldEditorsCnt = EditorRegistry.getEditors().length;
128128
let oldInputCnt = (<any>EditorRegistry).getEditorInputs().length;
129129

130-
EditorRegistry.registerEditor(d1, new SyncDescriptor(MyInput));
130+
EditorRegistry.registerEditor(d1, [new SyncDescriptor(MyInput)]);
131131
EditorRegistry.registerEditor(d2, [new SyncDescriptor(MyInput), new SyncDescriptor(MyOtherInput)]);
132132

133133
assert.equal(EditorRegistry.getEditors().length, oldEditorsCnt + 2);
@@ -148,8 +148,8 @@ suite('Workbench base editor', () => {
148148
let oldEditors = EditorRegistry.getEditors();
149149
(<any>EditorRegistry).setEditors([]);
150150

151-
EditorRegistry.registerEditor(d2, new SyncDescriptor(ResourceEditorInput));
152-
EditorRegistry.registerEditor(d1, new SyncDescriptor(MyResourceInput));
151+
EditorRegistry.registerEditor(d2, [new SyncDescriptor(ResourceEditorInput)]);
152+
EditorRegistry.registerEditor(d1, [new SyncDescriptor(MyResourceInput)]);
153153

154154
let inst = new TestInstantiationService();
155155

@@ -168,7 +168,7 @@ suite('Workbench base editor', () => {
168168
let oldEditors = EditorRegistry.getEditors();
169169
(<any>EditorRegistry).setEditors([]);
170170

171-
EditorRegistry.registerEditor(d1, new SyncDescriptor(ResourceEditorInput));
171+
EditorRegistry.registerEditor(d1, [new SyncDescriptor(ResourceEditorInput)]);
172172

173173
let inst = new TestInstantiationService();
174174

0 commit comments

Comments
 (0)