Merge VS Code 1.31.1 (#4283)

This commit is contained in:
Matt Irvine
2019-03-15 13:09:45 -07:00
committed by GitHub
parent 7d31575149
commit 86bac90001
1716 changed files with 53308 additions and 48375 deletions

View File

@@ -73,6 +73,9 @@ export function basename(resource: URI): string {
* @returns The URI representing the directory of the input URI.
*/
export function dirname(resource: URI): URI | null {
if (resource.path.length === 0) {
return resource;
}
if (resource.scheme === Schemas.file) {
return URI.file(paths.dirname(fsPath(resource)));
}
@@ -111,6 +114,9 @@ export function joinPath(resource: URI, pathFragment: string): URI {
* @returns The URI with the normalized path.
*/
export function normalizePath(resource: URI): URI {
if (!resource.path.length) {
return resource;
}
let normalizedPath: string;
if (resource.scheme === Schemas.file) {
normalizedPath = URI.file(paths.normalize(fsPath(resource))).path;
@@ -128,19 +134,20 @@ export function normalizePath(resource: URI): URI {
*/
export function fsPath(uri: URI): string {
let value: string;
if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') {
const uriPath = uri.path;
if (uri.authority && uriPath.length > 1 && uri.scheme === 'file') {
// unc path: file://shares/c$/far/boo
value = `//${uri.authority}${uri.path}`;
value = `//${uri.authority}${uriPath}`;
} else if (
isWindows
&& uri.path.charCodeAt(0) === CharCode.Slash
&& (uri.path.charCodeAt(1) >= CharCode.A && uri.path.charCodeAt(1) <= CharCode.Z || uri.path.charCodeAt(1) >= CharCode.a && uri.path.charCodeAt(1) <= CharCode.z)
&& uri.path.charCodeAt(2) === CharCode.Colon
&& uriPath.charCodeAt(0) === CharCode.Slash
&& paths.isWindowsDriveLetter(uriPath.charCodeAt(1))
&& uriPath.charCodeAt(2) === CharCode.Colon
) {
value = uri.path.substr(1);
value = uriPath.substr(1);
} else {
// other path
value = uri.path;
value = uriPath;
}
if (isWindows) {
value = value.replace(/\//g, '\\');
@@ -186,7 +193,7 @@ export function isMalformedFileUri(candidate: URI): URI | undefined {
if (!candidate.scheme || isWindows && candidate.scheme.match(/^[a-zA-Z]$/)) {
return URI.file((candidate.scheme ? candidate.scheme + ':' : '') + candidate.path);
}
return void 0;
return undefined;
}