Skip to content

Commit b739fe8

Browse files
committed
Limit scriptFileNames
1 parent 4590490 commit b739fe8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

server/src/services/typescriptService/serviceHost.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ export function getServiceHost(
6262
const vueSys = getVueSys(tsModule);
6363

6464
let currentScriptDoc: TextDocument;
65+
let scriptFileNames: string[] = [];
6566
const versions = new Map<string, number>();
6667
const scriptDocs = new Map<string, TextDocument>();
6768

6869
const parsedConfig = getParsedConfig(tsModule, workspacePath);
6970
const files = parsedConfig.fileNames;
7071
logger.logDebug(`Initializing ServiceHost with ${files.length} files: ${JSON.stringify(files)}`);
71-
const scriptFileNameSet = new Set(files);
7272

7373
const isOldVersion = inferIsOldVersion(tsModule, workspacePath);
7474
const compilerOptions = {
@@ -104,12 +104,12 @@ export function getServiceHost(
104104

105105
function updateCurrentTextDocument(doc: TextDocument) {
106106
const fileFsPath = getFileFsPath(doc.uri);
107-
const filePath = getFilePath(doc.uri);
108-
// When file is not in language service, add it
109-
if (!scriptDocs.has(fileFsPath)) {
110-
if (fileFsPath.endsWith('.vue') || fileFsPath.endsWith('.vue.template')) {
111-
scriptFileNameSet.add(filePath);
112-
}
107+
108+
if (fileFsPath.endsWith('.vue')) {
109+
scriptFileNames = [fileFsPath, fileFsPath + '.template'];
110+
}
111+
if (fileFsPath.endsWith('.vue.template')) {
112+
scriptFileNames = [fileFsPath.slice(0, -'.template'.length), fileFsPath];
113113
}
114114

115115
if (isVirtualVueTemplateFile(fileFsPath)) {
@@ -143,7 +143,7 @@ export function getServiceHost(
143143
function createLanguageServiceHost(options: ts.CompilerOptions): ts.LanguageServiceHost {
144144
return {
145145
getCompilationSettings: () => options,
146-
getScriptFileNames: () => Array.from(scriptFileNameSet),
146+
getScriptFileNames: () => scriptFileNames,
147147
getScriptVersion(fileName) {
148148
if (fileName === bridge.fileName) {
149149
return '0';

0 commit comments

Comments
 (0)