mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 20:25:23 -06:00
Fixing behavior of resolvePath
This commit is contained in:
parent
5c24b3528d
commit
ffc165ee36
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user