mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
Merge pull request #256256 from andy0130tw/andy0130tw/support-locale-argument-in-tsserver-web
Support the locale argument of TypeScript language server on the web version (#256252)
This commit is contained in:
@@ -16,7 +16,7 @@ export class PathMapper {
|
||||
* Copied from toResource in typescriptServiceClient.ts
|
||||
*/
|
||||
toResource(filepath: string): URI {
|
||||
if (looksLikeLibDtsPath(filepath)) {
|
||||
if (looksLikeLibDtsPath(filepath) || looksLikeLocaleResourcePath(filepath)) {
|
||||
return URI.from({
|
||||
scheme: this.extensionUri.scheme,
|
||||
authority: this.extensionUri.authority,
|
||||
@@ -83,6 +83,10 @@ export function looksLikeLibDtsPath(filepath: string) {
|
||||
return filepath.startsWith('/lib.') && filepath.endsWith('.d.ts');
|
||||
}
|
||||
|
||||
export function looksLikeLocaleResourcePath(filepath: string) {
|
||||
return !!filepath.match(/^\/[a-zA-Z]+(-[a-zA-Z]+)?\/diagnosticMessages\.generated\.json$/);
|
||||
}
|
||||
|
||||
export function looksLikeNodeModules(filepath: string) {
|
||||
return filepath.includes('/node_modules');
|
||||
}
|
||||
|
||||
@@ -41,6 +41,12 @@ async function initializeSession(
|
||||
removeEventListener('message', listener);
|
||||
});
|
||||
setSys(sys);
|
||||
|
||||
const localeStr = findArgument(args, '--locale');
|
||||
if (localeStr) {
|
||||
ts.validateLocaleAndSetLanguage(localeStr, sys);
|
||||
}
|
||||
|
||||
startWorkerSession(ts, sys, fs, sessionOptions, ports.tsserver, pathMapper, logger);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user