Skip to content

Commit

Permalink
fix: use original file path casing for shim files (#2591)
Browse files Browse the repository at this point in the history
#2584

Use original casing here: people could have their VS Code extensions in a case insensitive folder but their project in a case sensitive one; and if we copy the shims into the case sensitive part it would break when canonicalizing it.
  • Loading branch information
jasonlyu123 authored Nov 20, 2024
1 parent fba28b2 commit b6cac97
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/language-server/src/plugins/typescript/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ async function createLanguageService(
: undefined;

const changedFilesForExportCache = new Set<string>();
const svelteTsxFiles = getSvelteShimFiles();
const svelteTsxFilesToOriginalCasing = getSvelteShimFiles();

let languageServiceReducedMode = false;
let projectVersion = 0;
Expand Down Expand Up @@ -700,7 +700,10 @@ async function createLanguageService(
...clientFiles.filter(
(file) => !canonicalProjectFileNames.has(getCanonicalFileName(file))
),
...svelteTsxFiles
// Use original casing here, too: people could have their VS Code extensions in a case insensitive
// folder but their project in a case sensitive one; and if we copy the shims into the case sensitive
// part it would break when canonicalizing it.
...svelteTsxFilesToOriginalCasing.values()
])
);
}
Expand Down Expand Up @@ -1220,14 +1223,17 @@ async function createLanguageService(
svelteTsPath,
docContext.isSvelteCheck ? undefined : tsconfigPath || workspacePath
);
const result = new FileSet(tsSystem.useCaseSensitiveFileNames);
const pathToOriginalCasing = new Map<string, string>();
for (const file of svelteTsxFiles) {
const normalizedPath = normalizePath(file);
pathToOriginalCasing.set(getCanonicalFileName(normalizedPath), normalizedPath);
}

svelteTsxFiles.forEach((f) => result.add(normalizePath(f)));
return result;
return pathToOriginalCasing;
}

function isShimFiles(filePath: string) {
return svelteTsxFiles.has(normalizePath(filePath));
return svelteTsxFilesToOriginalCasing.has(getCanonicalFileName(normalizePath(filePath)));
}
}

Expand Down

0 comments on commit b6cac97

Please sign in to comment.