不用每个文件都查找一次i18n,提升性能

This commit is contained in:
Pan Qiancheng 2024-11-22 13:10:10 +08:00
parent 7a03e88943
commit 09fe290ad2
1 changed files with 6 additions and 2 deletions

View File

@ -23,17 +23,21 @@ class LocaleDocumentLinkProvider implements vscode.DocumentLinkProvider {
const tCallRegex = /(?<![a-zA-Z])t\(['"`]([^'"`]*)['"`]\)/g;
const documentLinks: vscode.DocumentLink[] = [];
const diagnostics: vscode.Diagnostic[] = [];
let match;
if (isLoadingLocale()) {
await waitUntilLocaleLoaded();
}
const match = tCallRegex.exec(text);
if (!match) {
return [];
}
getLocalesData(join(document.uri.fsPath, '../locales'));
while ((match = tCallRegex.exec(text)) !== null) {
while (match !== null) {
const key = match[1];
if (key.includes('${')) {
// 忽略动态key
continue;
}