Skip to content

Commit aa6ea25

Browse files
Fix generateOptionsSchema to add Locked array entry (#6413)
In #6387, the generator was partially modified to support generating correct localization comments, but the generated output was missing the `Locked` entry. This updates it to match.
1 parent 4202215 commit aa6ea25

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

package.nls.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
"message": "Array of symbol server URLs (example: http\u200b://MyExampleSymbolServer) or directories (example: /build/symbols) to search for .pdb files. These directories will be searched in addition to the default locations -- next to the module and the path where the pdb was originally dropped to.",
244244
"comment": [
245245
"We use '\u200b' (unicode zero-length space character) to break VS Code's URL detection regex for URLs that are examples. Please do not translate or localized the URL.",
246-
"{Locked='(example: http\u200b://MyExampleSymbolServer)'}"
246+
"{Locked='http\u200b://MyExampleSymbolServer'}"
247247
]
248248
},
249249
"generateOptionsSchema.symbolOptions.searchMicrosoftSymbolServer.description": {
@@ -307,4 +307,4 @@
307307
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
308308
]
309309
}
310-
}
310+
}

src/tools/generateOptionsSchema.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,31 @@ function generateCommentArrayForDescription(description: string): string[] {
159159

160160
// If the description contains '\u200b', it is used to prevent vscode from rendering a URL.
161161
if (description.includes('\u200b')) {
162+
const urlRegEx = new RegExp('https?\\u200b:[\\w/\\.\u200b]+', 'g');
163+
let result = urlRegEx.exec(description);
164+
if (!result) {
165+
throw `Found zero-with unicode space outside of expected URL in '${description}'`;
166+
}
167+
162168
comments.push(
163169
"We use '\u200b' (unicode zero-length space character) to break VS Code's URL detection regex for URLs that are examples. Please do not translate or localized the URL."
164170
);
171+
while (result !== null) {
172+
let foundText = result[0];
173+
174+
// check if the match is surrounded by `()`, and if so, include them
175+
if (
176+
result.index > 0 &&
177+
result.index + foundText.length < description.length &&
178+
description[result.index - 1] === '(' &&
179+
description[result.index + foundText.length] === ')'
180+
) {
181+
foundText = `(${foundText})`;
182+
}
183+
184+
comments.push(`{Locked='${foundText}'}`);
185+
result = urlRegEx.exec(description);
186+
}
165187
}
166188

167189
return comments;

0 commit comments

Comments
 (0)