mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
Use object instead of array for workbench.externalUriOpeners
This commit is contained in:
@@ -13,9 +13,8 @@ export const defaultExternalUriOpenerId = 'default';
|
||||
|
||||
export const externalUriOpenersSettingId = 'workbench.externalUriOpeners';
|
||||
|
||||
export interface ExternalUriOpenerConfiguration {
|
||||
readonly uri: string;
|
||||
readonly id: string;
|
||||
export interface ExternalUriOpenersConfiguration {
|
||||
readonly [uriGlob: string]: string;
|
||||
}
|
||||
|
||||
const externalUriOpenerIdSchemaAddition: IJSONSchema = {
|
||||
@@ -39,38 +38,27 @@ export const externalUriOpenersConfigurationNode: IConfigurationNode = {
|
||||
...workbenchConfigurationNodeBase,
|
||||
properties: {
|
||||
[externalUriOpenersSettingId]: {
|
||||
type: 'array',
|
||||
type: 'object',
|
||||
markdownDescription: nls.localize('externalUriOpeners', "Configure the opener to use for external uris (i.e. http, https)."),
|
||||
items: {
|
||||
type: 'object',
|
||||
defaultSnippets: [{
|
||||
body: {
|
||||
'uri': '$1',
|
||||
'id': '$2'
|
||||
}
|
||||
}],
|
||||
required: ['uri', 'id'],
|
||||
properties: {
|
||||
'uri': {
|
||||
type: 'string',
|
||||
markdownDescription: nls.localize('externalUriOpeners.uri', "Uri pattern that the opener applies to. Example patterns: \n{0}", exampleUriPatterns),
|
||||
},
|
||||
'id': {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'string',
|
||||
description: nls.localize('externalUriOpeners.id', "The id of the opener."),
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
description: nls.localize('externalUriOpeners.id', "The id of the opener."),
|
||||
enum: [defaultExternalUriOpenerId],
|
||||
enumDescriptions: [nls.localize('externalUriOpeners.defaultId', "Open using VS Code's standard opener.")],
|
||||
},
|
||||
externalUriOpenerIdSchemaAddition
|
||||
]
|
||||
}
|
||||
defaultSnippets: [{
|
||||
body: {
|
||||
'example.com': '$1'
|
||||
}
|
||||
}],
|
||||
additionalProperties: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'string',
|
||||
markdownDescription: nls.localize('externalUriOpeners.uri', "Map uri pattern to an opener id.\nExample patterns: \n{0}", exampleUriPatterns),
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
markdownDescription: nls.localize('externalUriOpeners.uri', "Map uri pattern to an opener id.\nExample patterns: \n{0}", exampleUriPatterns),
|
||||
enum: [defaultExternalUriOpenerId],
|
||||
enumDescriptions: [nls.localize('externalUriOpeners.defaultId', "Open using VS Code's standard opener.")],
|
||||
},
|
||||
externalUriOpenerIdSchemaAddition
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
|
||||
import { IExternalOpener, IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { IQuickInputService, IQuickPickItem, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { defaultExternalUriOpenerId, ExternalUriOpenerConfiguration, externalUriOpenersSettingId } from 'vs/workbench/contrib/externalUriOpener/common/configuration';
|
||||
import { defaultExternalUriOpenerId, ExternalUriOpenersConfiguration, externalUriOpenersSettingId } from 'vs/workbench/contrib/externalUriOpener/common/configuration';
|
||||
import { testUrlMatchesGlob } from 'vs/workbench/contrib/url/common/urlGlob';
|
||||
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
|
||||
|
||||
@@ -139,9 +139,9 @@ export class ExternalUriOpenerService extends Disposable implements IExternalUri
|
||||
}
|
||||
|
||||
private getConfiguredOpenerForUri(openers: Map<string, IExternalUriOpener>, targetUri: URI): IExternalUriOpener | 'default' | undefined {
|
||||
const config = this.configurationService.getValue<readonly ExternalUriOpenerConfiguration[]>(externalUriOpenersSettingId) || [];
|
||||
for (const { id, uri } of config) {
|
||||
if (testUrlMatchesGlob(targetUri.toString(), uri)) {
|
||||
const config = this.configurationService.getValue<ExternalUriOpenersConfiguration>(externalUriOpenersSettingId) || {};
|
||||
for (const [uriGlob, id] of Object.entries(config)) {
|
||||
if (testUrlMatchesGlob(targetUri.toString(), uriGlob)) {
|
||||
if (id === defaultExternalUriOpenerId) {
|
||||
return 'default';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user