Fix bug: normalize path after combining (#21100)

This commit is contained in:
Andy 2018-01-09 11:54:35 -08:00 committed by GitHub
parent 191b9750c3
commit fed34cd616
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View file

@ -216,7 +216,8 @@ namespace ts.Completions.PathCompletions {
const expandedPrefixDirectory = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + getDirectoryPath(fragment)) : normalizedPrefixDirectory;
const normalizedSuffix = normalizePath(parsed.suffix);
const baseDirectory = combinePaths(baseUrl, expandedPrefixDirectory);
// Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b".
const baseDirectory = normalizePath(combinePaths(baseUrl, expandedPrefixDirectory));
const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase;
// If we have a suffix, then we need to read the directory all the way down. We could create a glob

View file

@ -0,0 +1,20 @@
/// <reference path="fourslash.ts" />
// @Filename: /src/a.ts
////import { } from "foo/[|/**/|]";
// @Filename: /oof/x.ts
////export const x = 0;
// @Filename: /tsconfig.json
////{
//// "compilerOptions": {
//// "baseUrl": "src",
//// "paths": {
//// "foo/*": ["../oof/*"]
//// }
//// }
////}
const [replacementSpan] = test.ranges();
verify.completionsAt("", [{ name: "x", replacementSpan }]);