mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Lookup files by resolved Path and not by fileName in sourcemapDecoder when querying program (#25908)
* Check if the file returned by the program actually refers to the same file as we intend * Simplify
This commit is contained in:
@@ -98,10 +98,10 @@ namespace ts.sourcemaps {
|
||||
|
||||
function getSourceFileLike(fileName: string, location: string): SourceFileLike | undefined {
|
||||
// Lookup file in program, if provided
|
||||
const file = program && program.getSourceFile(fileName);
|
||||
const path = toPath(fileName, location, host.getCanonicalFileName);
|
||||
const file = program && program.getSourceFile(path);
|
||||
if (!file) {
|
||||
// Otherwise check the cache (which may hit disk)
|
||||
const path = toPath(fileName, location, host.getCanonicalFileName);
|
||||
return fallbackCache.get(path);
|
||||
}
|
||||
return file;
|
||||
|
||||
@@ -709,7 +709,7 @@ namespace FourSlash {
|
||||
|
||||
ts.zipWith(endMarkers, definitions, (endMarker, definition, i) => {
|
||||
const marker = this.getMarkerByName(endMarker);
|
||||
if (marker.fileName !== definition.fileName || marker.position !== definition.textSpan.start) {
|
||||
if (ts.comparePaths(marker.fileName, definition.fileName, /*ignoreCase*/ true) !== ts.Comparison.EqualTo || marker.position !== definition.textSpan.start) {
|
||||
this.raiseError(`${testName} failed for definition ${endMarker} (${i}): expected ${marker.fileName} at ${marker.position}, got ${definition.fileName} at ${definition.textSpan.start}`);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user