Skip to content

Commit b49ce99

Browse files
Fix parsing binding setting with missing help resource (#3601)
1 parent 746ad40 commit b49ce99

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/templates/script/parseScriptTemplates.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,20 @@ function getVariableValue(resources: IResources, variables: IVariables, data: st
9292
return getResourceValue(resources, data);
9393
}
9494

95-
export function getResourceValue(resources: IResources, data: string): string {
95+
96+
export function getResourceValue(resources: IResources, data: string, dontThrow: true): string | undefined;
97+
export function getResourceValue(resources: IResources, data: string, dontThrow?: false): string;
98+
export function getResourceValue(resources: IResources, data: string, dontThrow: boolean | undefined): string | undefined {
9699
const matches: RegExpMatchArray | null = data.match(/\$(.*)/);
97100
if (matches === null) {
98101
return data;
99102
} else {
100103
const key: string = matches[1];
101104
const result: string | undefined = resources.lang && resources.lang[key] ? resources.lang[key] : resources.en[key];
102105
if (result === undefined) {
106+
if (dontThrow) {
107+
return undefined;
108+
}
103109
throw new Error(localize('resourceNotFound', 'Resource "{0}" not found.', data));
104110
} else {
105111
return result;
@@ -119,11 +125,19 @@ function parseScriptSetting(data: object, resources: IResources, variables: IVar
119125
}
120126
}
121127

128+
function getDescription(): string | undefined {
129+
if (rawSetting.help) {
130+
const resourceValue = getResourceValue(resources, rawSetting.help, true);
131+
return resourceValue ? replaceHtmlLinkWithMarkdown(resourceValue) : undefined;
132+
}
133+
return undefined;
134+
}
135+
122136
return {
123137
name: getVariableValue(resources, variables, rawSetting.name),
124138
resourceType: rawSetting.resource,
125139
valueType: rawSetting.value,
126-
description: rawSetting.help ? replaceHtmlLinkWithMarkdown(getResourceValue(resources, rawSetting.help)) : undefined,
140+
description: getDescription(),
127141
defaultValue: rawSetting.defaultValue,
128142
label: getVariableValue(resources, variables, rawSetting.label),
129143
enums: enums,

0 commit comments

Comments
 (0)