Skip to content

Commit 47308ca

Browse files
authored
(fix) ignore updated files not belonging to project (#2006)
#2005
1 parent 09a2dbd commit 47308ca

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/language-server/src/plugins/typescript/service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export interface LanguageServiceContainer {
4343
* Careful, don't call often, or it will hurt performance.
4444
* Only works for TS versions that have ScriptKind.Deferred
4545
*/
46-
fileBelongsToProject(filePath: string): boolean;
46+
fileBelongsToProject(filePath: string, isNew: boolean): boolean;
4747

4848
dispose(): void;
4949
}
@@ -368,9 +368,9 @@ async function createLanguageService(
368368
return snapshotManager.has(filePath);
369369
}
370370

371-
function fileBelongsToProject(filePath: string): boolean {
371+
function fileBelongsToProject(filePath: string, isNew: boolean): boolean {
372372
filePath = normalizePath(filePath);
373-
return hasFile(filePath) || getParsedConfig().fileNames.includes(filePath);
373+
return hasFile(filePath) || (isNew && getParsedConfig().fileNames.includes(filePath));
374374
}
375375

376376
function updateTsOrJsFile(fileName: string, changes?: TextDocumentContentChangeEvent[]): void {

packages/language-server/src/svelte-check.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ export class SvelteCheck {
109109
async upsertDocument(doc: { text: string; uri: string }, isNew: boolean): Promise<void> {
110110
const filePath = urlToPath(doc.uri) || '';
111111

112-
if (isNew && this.options.tsconfig) {
112+
if (this.options.tsconfig) {
113113
const lsContainer = await this.getLSContainer(this.options.tsconfig);
114-
if (!lsContainer.fileBelongsToProject(filePath)) {
114+
if (!lsContainer.fileBelongsToProject(filePath, isNew)) {
115115
return;
116116
}
117117
}

0 commit comments

Comments
 (0)