fix commonPrefix handling

This commit is contained in:
Klaus Meinhardt 2018-08-08 16:58:35 +02:00
parent 1a05f13aef
commit 95494efe50

View file

@ -407,18 +407,17 @@ namespace ts {
// directory: /a/b/c/d/e
// resolvedFileName: /a/b/foo.d.ts
const commonPrefix = getCommonPrefix(path, resolvedFileName);
if (commonPrefix === undefined) {
return;
}
let current = path;
while (true) {
while (current !== commonPrefix) {
const parent = getDirectoryPath(current);
if (parent === current || directoryPathMap.has(parent)) {
break;
}
directoryPathMap.set(parent, result);
current = parent;
if (current === commonPrefix) {
break;
}
}
}
@ -434,6 +433,10 @@ namespace ts {
i++;
}
if (i === directory.length && resolutionDirectory.length > i && resolutionDirectory[i] === directorySeparator) {
return directory;
}
// find last directory separator before position i
const sep = directory.lastIndexOf(directorySeparator, i);
if (sep < 0) {