Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use original file path casing for shim files #2591

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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