This commit is contained in:
Johannes Rieken
2017-07-28 11:46:43 +02:00
parent 281cf3934d
commit a154372764
4 changed files with 35 additions and 6 deletions

View File

@@ -386,8 +386,8 @@ export function createApiFactory(
apiUsage.publicLog('workspace#onDidChangeWorkspaceFolders');
return extHostWorkspace.onDidChangeWorkspace(listener, thisArgs, disposables);
},
asRelativePath: (pathOrUri) => {
return extHostWorkspace.getRelativePath(pathOrUri);
asRelativePath: (pathOrUri, includeWorkspace) => {
return extHostWorkspace.getRelativePath(pathOrUri, includeWorkspace);
},
findFiles: (include, exclude, maxResults?, token?) => {
return extHostWorkspace.findFiles(include, exclude, maxResults, token);

View File

@@ -117,7 +117,7 @@ export class ExtHostWorkspace extends ExtHostWorkspaceShape {
return roots[0].fsPath;
}
getRelativePath(pathOrUri: string | vscode.Uri): string {
getRelativePath(pathOrUri: string | vscode.Uri, includeWorkspace?: boolean): string {
let path: string;
if (typeof pathOrUri === 'string') {
@@ -139,8 +139,12 @@ export class ExtHostWorkspace extends ExtHostWorkspaceShape {
return normalize(path);
}
if (typeof includeWorkspace === 'undefined') {
includeWorkspace = this.workspace.roots.length > 1;
}
let result = relative(folder.uri.fsPath, path);
if (this.workspace.roots.length > 1) {
if (includeWorkspace) {
result = `${folder.name}/${result}`;
}
return normalize(result);