Handle case sensitivity correctly in source map decoder

This commit is contained in:
Sheetal Nandi
2018-10-31 15:14:08 -07:00
parent 3a2f7c0df1
commit efe5dd6b6d
3 changed files with 12 additions and 5 deletions
+3 -2
View File
@@ -57,6 +57,7 @@ namespace ts.sourcemaps {
fileExists(path: string): boolean;
getCanonicalFileName(path: string): string;
log(text: string): void;
useCaseSensitiveFileNames: boolean;
}
export function decode(host: SourceMapDecodeHost, mapPath: string, map: SourceMapData, program?: Program, fallbackCache = createSourceFileLikeCache(host)): SourceMapper {
@@ -79,7 +80,7 @@ namespace ts.sourcemaps {
// if no exact match, closest is 2's compliment of result
targetIndex = ~targetIndex;
}
if (!maps[targetIndex] || comparePaths(loc.fileName, maps[targetIndex].sourcePath, sourceRoot) !== 0) {
if (!maps[targetIndex] || comparePaths(loc.fileName, maps[targetIndex].sourcePath, sourceRoot, !host.useCaseSensitiveFileNames) !== 0) {
return loc;
}
return { fileName: toPath(map.file!, sourceRoot, host.getCanonicalFileName), position: maps[targetIndex].emittedPosition }; // Closest pos
@@ -129,7 +130,7 @@ namespace ts.sourcemaps {
}
function compareProcessedPositionSourcePositions(a: ProcessedSourceMapPosition, b: ProcessedSourceMapPosition) {
return comparePaths(a.sourcePath, b.sourcePath, sourceRoot) ||
return comparePaths(a.sourcePath, b.sourcePath, sourceRoot, !host.useCaseSensitiveFileNames) ||
compareValues(a.sourcePosition, b.sourcePosition);
}