diff --git a/src/vs/workbench/services/editor/browser/editorResolverService.ts b/src/vs/workbench/services/editor/browser/editorResolverService.ts index 6731ee8717c10..18b9a9559e7af 100644 --- a/src/vs/workbench/services/editor/browser/editorResolverService.ts +++ b/src/vs/workbench/services/editor/browser/editorResolverService.ts @@ -114,7 +114,6 @@ export class EditorResolverService extends Disposable implements IEditorResolver } let resource = EditorResourceAccessor.getCanonicalUri(untypedEditor, { supportSideBySide: SideBySideEditor.PRIMARY }); - const options = untypedEditor.options; // If it was resolved before we await for the extensions to activate and then proceed with resolution or else the backing extensions won't be registered if (this.cache && resource && this.resourceMatchesCache(resource)) { @@ -178,12 +177,6 @@ export class EditorResolverService extends Disposable implements IEditorResolver return ResolvedStatus.NONE; } - // If it's the currently active editor we shouldn't do anything - const activeEditor = group.activeEditor; - const isActive = activeEditor ? activeEditor.matches(untypedEditor) : false; - if (activeEditor && isActive) { - return { editor: activeEditor, options, group }; - } const input = await this.doResolveEditor(untypedEditor, group, selectedEditor); if (conflictingDefault && input) { // Show the conflicting default dialog diff --git a/src/vs/workbench/services/editor/test/browser/editorService.test.ts b/src/vs/workbench/services/editor/test/browser/editorService.test.ts index b1ed8b75d2b73..fb23ed1feeef8 100644 --- a/src/vs/workbench/services/editor/test/browser/editorService.test.ts +++ b/src/vs/workbench/services/editor/test/browser/editorService.test.ts @@ -7,7 +7,7 @@ import * as assert from 'assert'; import { EditorActivation, IResourceEditorInput } from 'vs/platform/editor/common/editor'; import { URI } from 'vs/base/common/uri'; import { Event } from 'vs/base/common/event'; -import { DEFAULT_EDITOR_ASSOCIATION, EditorCloseContext, EditorsOrder, IEditorCloseEvent, EditorInputWithOptions, IEditorPane, IResourceDiffEditorInput, isEditorInputWithOptions, IUntitledTextResourceEditorInput, IUntypedEditorInput, SideBySideEditor } from 'vs/workbench/common/editor'; +import { DEFAULT_EDITOR_ASSOCIATION, EditorCloseContext, EditorsOrder, IEditorCloseEvent, EditorInputWithOptions, IEditorPane, IResourceDiffEditorInput, isEditorInputWithOptions, IUntitledTextResourceEditorInput, IUntypedEditorInput, SideBySideEditor, isEditorInput } from 'vs/workbench/common/editor'; import { workbenchInstantiationService, TestServiceAccessor, registerTestEditor, TestFileEditorInput, ITestInstantiationService, registerTestResourceEditor, registerTestSideBySideEditor, createEditorPart, registerTestFileEditor, TestTextFileEditor, TestSingletonFileEditorInput } from 'vs/workbench/test/browser/workbenchTestServices'; import { EditorService } from 'vs/workbench/services/editor/browser/editorService'; import { IEditorGroup, IEditorGroupsService, GroupDirection, GroupsArrangement } from 'vs/workbench/services/editor/common/editorGroupsService'; @@ -602,8 +602,13 @@ suite('EditorService', () => { async function openEditor(editor: EditorInputWithOptions | IUntypedEditorInput, group?: PreferredGroup): Promise { if (useOpenEditors) { + // The type safety isn't super good here, so we assist with runtime checks + // Open editors expects untyped or editor input with options, you cannot pass a typed editor input + // without options + if (!isEditorInputWithOptions(editor) && isEditorInput(editor)) { + editor = { editor: editor, options: {} }; + } const panes = await service.openEditors([editor], group); - return panes[0]; } @@ -651,7 +656,7 @@ suite('EditorService', () => { assert.ok(typedEditor instanceof TestFileEditorInput); assert.strictEqual(typedEditor?.resource?.toString(), untypedEditorReplacement.resource.toString()); - assert.strictEqual(editorFactoryCalled, 2); + assert.strictEqual(editorFactoryCalled, 3); assert.strictEqual(untitledEditorFactoryCalled, 0); assert.strictEqual(diffEditorFactoryCalled, 0); @@ -881,7 +886,6 @@ suite('EditorService', () => { assert.strictEqual(untitledEditorFactoryCalled, 0); assert.strictEqual(diffEditorFactoryCalled, 0); - assert.ok(!lastEditorFactoryEditor); assert.ok(!lastUntitledEditorFactoryEditor); assert.ok(!lastDiffEditorFactoryEditor);