chore(vscode): update to 1.54.2

This commit is contained in:
Joe Previte
2021-03-11 10:27:10 -07:00
1459 changed files with 53404 additions and 51004 deletions

View File

@@ -3,6 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import { Event } from 'vs/base/common/event';
import { EditorInput } from 'vs/workbench/common/editor';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { Registry } from 'vs/platform/registry/common/platform';
@@ -10,9 +12,27 @@ import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { IConstructorSignature0, IInstantiationService, BrandedService } from 'vs/platform/instantiation/common/instantiation';
import { insert } from 'vs/base/common/arrays';
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuration';
import { Extensions as ConfigurationExtensions, IConfigurationNode, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
export const Extensions = {
Editors: 'workbench.contributions.editors',
Associations: 'workbench.editors.associations'
};
//#region Editors Registry
export interface IEditorDescriptor {
/**
* The unique identifier of the editor
*/
getId(): string;
/**
* The display name of the editor
*/
getName(): string;
instantiate(instantiationService: IInstantiationService): EditorPane;
@@ -174,8 +194,137 @@ class EditorRegistry implements IEditorRegistry {
}
}
export const Extensions = {
Editors: 'workbench.contributions.editors'
Registry.add(Extensions.Editors, new EditorRegistry());
//#endregion
//#region Editor Associations
export const editorsAssociationsSettingId = 'workbench.editorAssociations';
export const DEFAULT_EDITOR_ASSOCIATION: IEditorType = {
id: 'default',
displayName: localize('promptOpenWith.defaultEditor.displayName', "Text Editor"),
providerDisplayName: localize('builtinProviderDisplayName', "Built-in")
};
Registry.add(Extensions.Editors, new EditorRegistry());
export type EditorAssociation = {
readonly viewType: string;
readonly filenamePattern?: string;
};
export type EditorsAssociations = readonly EditorAssociation[];
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
const editorTypeSchemaAddition: IJSONSchema = {
type: 'string',
enum: []
};
const editorAssociationsConfigurationNode: IConfigurationNode = {
...workbenchConfigurationNodeBase,
properties: {
'workbench.editorAssociations': {
type: 'array',
markdownDescription: localize('editor.editorAssociations', "Configure which editor to use for specific file types."),
items: {
type: 'object',
defaultSnippets: [{
body: {
'viewType': '$1',
'filenamePattern': '$2'
}
}],
properties: {
'viewType': {
anyOf: [
{
type: 'string',
description: localize('editor.editorAssociations.viewType', "The unique id of the editor to use."),
},
editorTypeSchemaAddition
]
},
'filenamePattern': {
type: 'string',
description: localize('editor.editorAssociations.filenamePattern', "Glob pattern specifying which files the editor should be used for."),
}
}
}
}
}
};
export interface IEditorType {
readonly id: string;
readonly displayName: string;
readonly providerDisplayName: string;
}
export interface IEditorTypesHandler {
readonly onDidChangeEditorTypes: Event<void>;
getEditorTypes(): IEditorType[];
}
export interface IEditorAssociationsRegistry {
/**
* Register handlers for editor types
*/
registerEditorTypesHandler(id: string, handler: IEditorTypesHandler): IDisposable;
}
class EditorAssociationsRegistry implements IEditorAssociationsRegistry {
private readonly editorTypesHandlers = new Map<string, IEditorTypesHandler>();
registerEditorTypesHandler(id: string, handler: IEditorTypesHandler): IDisposable {
if (this.editorTypesHandlers.has(id)) {
throw new Error(`An editor type handler with ${id} was already registered.`);
}
this.editorTypesHandlers.set(id, handler);
this.updateEditorAssociationsSchema();
const editorTypeChangeEvent = handler.onDidChangeEditorTypes(() => {
this.updateEditorAssociationsSchema();
});
return {
dispose: () => {
editorTypeChangeEvent.dispose();
this.editorTypesHandlers.delete(id);
this.updateEditorAssociationsSchema();
}
};
}
private updateEditorAssociationsSchema() {
const enumValues: string[] = [];
const enumDescriptions: string[] = [];
const editorTypes: IEditorType[] = [DEFAULT_EDITOR_ASSOCIATION];
for (const [, handler] of this.editorTypesHandlers) {
editorTypes.push(...handler.getEditorTypes());
}
for (const { id, providerDisplayName } of editorTypes) {
enumValues.push(id);
enumDescriptions.push(localize('editorAssociations.viewType.sourceDescription', "Source: {0}", providerDisplayName));
}
editorTypeSchemaAddition.enum = enumValues;
editorTypeSchemaAddition.enumDescriptions = enumDescriptions;
configurationRegistry.notifyConfigurationSchemaUpdated(editorAssociationsConfigurationNode);
}
}
Registry.add(Extensions.Associations, new EditorAssociationsRegistry());
configurationRegistry.registerConfiguration(editorAssociationsConfigurationNode);
//#endregion