editors - more removal of "override"

//cc @lramos15
This commit is contained in:
Benjamin Pasero 2021-07-08 12:52:16 +02:00
parent 31152fd902
commit 45298b83ea
8 changed files with 42 additions and 42 deletions

View file

@ -164,17 +164,17 @@ export enum EditorActivation {
export enum EditorResolution {
/**
* Displays a picker and allows the user to decide which editor to use
* Displays a picker and allows the user to decide which editor to use.
*/
PICK,
/**
* Disables overrides
* Disables editor resolving.
*/
DISABLED,
/**
* Only exclusive overrides are considered
* Only exclusive editors are considered.
*/
EXCLUSIVE_ONLY
}
@ -273,7 +273,7 @@ export interface IEditorOptions {
* Allows to override the editor that should be used to display the input:
* - `undefined`: let the editor decide for itself
* - `string`: specific override by id
* - `EditorOverride`: specific override handling
* - `EditorResolution`: specific override handling
*/
override?: string | EditorResolution;

View file

@ -496,7 +496,7 @@ export interface IEditorInput extends IDisposable {
/**
* Identifies the type of editor this input represents
* This ID is registered with the {@link EditorOverrideService} to allow
* This ID is registered with the {@link EditorResolverService} to allow
* for resolving an untyped input to a typed one
*/
readonly editorId: string | undefined;

View file

@ -35,7 +35,7 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ
private readonly _contributedEditors: ContributedCustomEditors;
private _untitledCounter = 0;
private readonly _editorOverrideDisposables: IDisposable[] = [];
private readonly _editorResolverDisposables: IDisposable[] = [];
private readonly _editorCapabilities = new Map<string, CustomEditorCapabilities>();
private readonly _models = new CustomEditorModelManager();
@ -108,13 +108,13 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ
private registerContributionPoints(): void {
// Clear all previous contributions we know
this._editorOverrideDisposables.forEach(d => d.dispose());
this._editorResolverDisposables.forEach(d => d.dispose());
for (const contributedEditor of this._contributedEditors) {
for (const globPattern of contributedEditor.selector) {
if (!globPattern.filenamePattern) {
continue;
}
this._editorOverrideDisposables.push(this._register(this.editorResolverService.registerEditor(
this._editorResolverDisposables.push(this._register(this.editorResolverService.registerEditor(
globPattern.filenamePattern,
{
id: contributedEditor.id,

View file

@ -44,15 +44,15 @@ export class PreferencesContribution implements IWorkbenchContribution {
) {
this.settingsListener = this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(USE_SPLIT_JSON_SETTING)) {
this.handleSettingsEditorOverride();
this.handleSettingsEditorRegistration();
}
});
this.handleSettingsEditorOverride();
this.handleSettingsEditorRegistration();
this.start();
}
private handleSettingsEditorOverride(): void {
private handleSettingsEditorRegistration(): void {
// dispose any old listener we had
dispose(this.editorOpeningListener);

View file

@ -460,9 +460,9 @@ export class EditorResolverService extends Disposable implements IEditorResolver
}
const handle = this.notificationService.prompt(Severity.Warning,
localize('editorOverride.conflictingDefaults', 'There are multiple default editors available for the resource.'),
localize('editorResolver.conflictingDefaults', 'There are multiple default editors available for the resource.'),
[{
label: localize('editorOverride.configureDefault', 'Configure Default'),
label: localize('editorResolver.configureDefault', 'Configure Default'),
run: async () => {
// Show the picker and tell it to update the setting to whatever the user selected
const picked = await this.doPickEditor(untypedInput, true);
@ -485,7 +485,7 @@ export class EditorResolverService extends Disposable implements IEditorResolver
}
},
{
label: localize('editorOverride.keepDefault', 'Keep {0}', editorName),
label: localize('editorResolver.keepDefault', 'Keep {0}', editorName),
run: writeCurrentEditorsToStorage
}
]);

View file

@ -58,7 +58,7 @@ export interface IEditorType {
configurationRegistry.registerConfiguration(editorAssociationsConfigurationNode);
//#endregion
//#region EditorOverrideService types
//#region EditorResolverService types
export enum RegisteredEditorPriority {
builtin = 'builtin',
option = 'option',
@ -69,7 +69,7 @@ export enum RegisteredEditorPriority {
/**
* If we didn't resolve an editor dictates what to do with the opening state
* ABORT = Do not continue with opening the editor
* NONE = Continue as if the override has been disabled as the service could not resolve one
* NONE = Continue as if the resolution has been disabled as the service could not resolve one
*/
export const enum ResolvedStatus {
ABORT = 1,

View file

@ -13,9 +13,9 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor
import { IEditorResolverService, ResolvedStatus, RegisteredEditorPriority } from 'vs/workbench/services/editor/common/editorResolverService';
import { createEditorPart, ITestInstantiationService, TestFileEditorInput, TestServiceAccessor, workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
suite('EditorOverrideService', () => {
suite('EditorResolverService', () => {
const TEST_EDITOR_INPUT_ID = 'testEditorInputForEditorOverrideService';
const TEST_EDITOR_INPUT_ID = 'testEditorInputForEditorResolverService';
const disposables = new DisposableStore();
teardown(() => disposables.clear());

View file

@ -1966,11 +1966,11 @@ suite('EditorService', () => {
assert.strictEqual(editorContextKeyService, part.activeGroup.activeEditorPane?.scopedContextKeyService);
});
test('editorOverrideService - openEditor', async function () {
test('editorResolverService - openEditor', async function () {
const [, service, accessor] = await createEditorService();
const editorOverrideService = accessor.editorResolverService;
let overrideCount = 0;
const registrationDisposable = editorOverrideService.registerEditor(
const editorResolverService = accessor.editorResolverService;
let editorCount = 0;
const registrationDisposable = editorResolverService.registerEditor(
'*.md',
{
id: 'TestEditor',
@ -1980,33 +1980,33 @@ suite('EditorService', () => {
},
{},
(editorInput) => {
overrideCount++;
editorCount++;
return ({ editor: service.createEditorInput(editorInput) });
},
undefined,
diffEditor => ({ editor: service.createEditorInput(diffEditor) })
);
assert.strictEqual(overrideCount, 0);
assert.strictEqual(editorCount, 0);
const input1 = { resource: URI.parse('file://test/path/resource1.txt') };
const input2 = { resource: URI.parse('file://test/path/resource1.md') };
// Open editor input 1 and it shouln't trigger override as the glob doesn't match
await service.openEditor(input1);
assert.strictEqual(overrideCount, 0);
assert.strictEqual(editorCount, 0);
// Open editor input 2 and it should trigger override as the glob doesn match
await service.openEditor(input2);
assert.strictEqual(overrideCount, 1);
assert.strictEqual(editorCount, 1);
// Because we specify an override we shouldn't see it triggered even if it matches
await service.openEditor({ ...input2, options: { override: 'default' } });
assert.strictEqual(overrideCount, 1);
assert.strictEqual(editorCount, 1);
registrationDisposable.dispose();
});
test('editorOverrideService - openEditors', async function () {
test('editorResolverService - openEditors', async function () {
const [, service, accessor] = await createEditorService();
const editorOverrideService = accessor.editorResolverService;
let overrideCount = 0;
const registrationDisposable = editorOverrideService.registerEditor(
const editorResolverService = accessor.editorResolverService;
let editorCount = 0;
const registrationDisposable = editorResolverService.registerEditor(
'*.md',
{
id: 'TestEditor',
@ -2016,29 +2016,29 @@ suite('EditorService', () => {
},
{},
(editorInput) => {
overrideCount++;
editorCount++;
return ({ editor: service.createEditorInput(editorInput) });
},
undefined,
diffEditor => ({ editor: service.createEditorInput(diffEditor) })
);
assert.strictEqual(overrideCount, 0);
assert.strictEqual(editorCount, 0);
const input1 = new TestFileEditorInput(URI.parse('file://test/path/resource1.txt'), TEST_EDITOR_INPUT_ID);
const input2 = new TestFileEditorInput(URI.parse('file://test/path/resource2.txt'), TEST_EDITOR_INPUT_ID);
const input3 = new TestFileEditorInput(URI.parse('file://test/path/resource3.md'), TEST_EDITOR_INPUT_ID);
const input4 = new TestFileEditorInput(URI.parse('file://test/path/resource4.md'), TEST_EDITOR_INPUT_ID);
// Open editor input 1 and it shouln't trigger override as the glob doesn't match
await service.openEditors([{ editor: input1 }, { editor: input2 }, { editor: input3 }, { editor: input4 }]);
assert.strictEqual(overrideCount, 2);
assert.strictEqual(editorCount, 2);
registrationDisposable.dispose();
});
test('editorOverrideService - replaceEditors', async function () {
test('editorResolverService - replaceEditors', async function () {
const [part, service, accessor] = await createEditorService();
const editorOverrideService = accessor.editorResolverService;
let overrideCount = 0;
const registrationDisposable = editorOverrideService.registerEditor(
const editorResolverService = accessor.editorResolverService;
let editorCount = 0;
const registrationDisposable = editorResolverService.registerEditor(
'*.md',
{
id: 'TestEditor',
@ -2048,22 +2048,22 @@ suite('EditorService', () => {
},
{},
(editorInput) => {
overrideCount++;
editorCount++;
return ({ editor: service.createEditorInput(editorInput) });
},
undefined,
diffEditor => ({ editor: service.createEditorInput(diffEditor) })
);
assert.strictEqual(overrideCount, 0);
assert.strictEqual(editorCount, 0);
const input1 = new TestFileEditorInput(URI.parse('file://test/path/resource2.md'), TEST_EDITOR_INPUT_ID);
// Open editor input 1 and it shouldn't trigger because I've disabled the override logic
await service.openEditor(input1, { override: EditorResolution.DISABLED });
assert.strictEqual(overrideCount, 0);
assert.strictEqual(editorCount, 0);
await service.replaceEditors([{
editor: input1,
replacement: input1,
}], part.activeGroup);
assert.strictEqual(overrideCount, 1);
assert.strictEqual(editorCount, 1);
registrationDisposable.dispose();
});