Skip to content

Commit

Permalink
lramos15/xenacious-bedbug (#165083)
Browse files Browse the repository at this point in the history
* Don't shortcircuit active editor in Resolver

* Fix broken test
  • Loading branch information
lramos15 authored Nov 1, 2022
1 parent 3a8b7e4 commit ccda672
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -602,8 +602,13 @@ suite('EditorService', () => {

async function openEditor(editor: EditorInputWithOptions | IUntypedEditorInput, group?: PreferredGroup): Promise<IEditorPane | undefined> {
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];
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -881,7 +886,6 @@ suite('EditorService', () => {
assert.strictEqual(untitledEditorFactoryCalled, 0);
assert.strictEqual(diffEditorFactoryCalled, 0);

assert.ok(!lastEditorFactoryEditor);
assert.ok(!lastUntitledEditorFactoryEditor);
assert.ok(!lastDiffEditorFactoryEditor);

Expand Down

0 comments on commit ccda672

Please sign in to comment.