Fixing behavior of resolvePath

This commit is contained in:
Richard Knoll 2016-07-05 17:38:52 -07:00
parent 5c24b3528d
commit ffc165ee36
2 changed files with 4 additions and 18 deletions

View File

@ -219,21 +219,7 @@ namespace Harness.LanguageService {
return snapshot.getText(0, snapshot.getLength());
}
resolvePath(path: string): string {
// Reduce away "." and ".."
const parts = path.split("/");
const res: string[] = [];
for (let i = 0; i < parts.length; i++) {
if (parts[i] === ".") {
continue;
}
else if (parts[i] === ".." && res.length > 0) {
res.splice(res.length - 1, 1);
}
else {
res.push(parts[i]);
}
}
return res.join("/");
return ts.normalizePath(ts.isRootedDiskPath(path) ? path : ts.combinePaths(this.getCurrentDirectory(), path));
}

View File

@ -4389,13 +4389,13 @@ namespace ts {
const toComplete = getBaseFileName(fragment);
const absolutePath = normalizeSlashes(host.resolvePath(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment)));
const baseDir = getDirectoryPath(absolutePath);
const baseDir = toComplete ? getDirectoryPath(absolutePath) : absolutePath;
if (directoryProbablyExists(baseDir, host)) {
// Enumerate the available files
const files = host.readDirectory(baseDir, extensions, /*exclude*/undefined, /*include*/["./*"]);
ts.forEach(files, (f) => {
forEach(files, (f) => {
const fName = includeExtensions ? getBaseFileName(f) : removeFileExtension(getBaseFileName(f));
if (startsWith(fName, toComplete)) {
@ -4411,7 +4411,7 @@ namespace ts {
// If possible, get folder completion as well
if (host.getDirectories) {
const directories = host.getDirectories(baseDir);
ts.forEach(directories, (d) => {
forEach(directories, (d) => {
const dName = getBaseFileName(removeTrailingDirectorySeparator(d));
if (startsWith(dName, toComplete)) {