Merge from vscode cfbd1999769f4f08dce29629fb92fdc0fac53829

This commit is contained in:
ADS Merger
2020-08-06 07:08:52 +00:00
parent 9c67832880
commit 540046ba00
362 changed files with 7588 additions and 6584 deletions

View File

@@ -126,6 +126,8 @@ function relativePathToUri(path: string, resultsUri: vscode.Uri): vscode.Uri | u
return vscode.Uri.file(pathUtils.join(process.env.HOME!, path.slice(2)));
}
const uriFromFolderWithPath = (folder: vscode.WorkspaceFolder, path: string): vscode.Uri =>
folder.uri.with({ path: pathUtils.join(folder.uri.fsPath, path) });
if (vscode.workspace.workspaceFolders) {
const multiRootFormattedPath = /^(.*) • (.*)$/.exec(path);
@@ -133,17 +135,18 @@ function relativePathToUri(path: string, resultsUri: vscode.Uri): vscode.Uri | u
const [, workspaceName, workspacePath] = multiRootFormattedPath;
const folder = vscode.workspace.workspaceFolders.filter(wf => wf.name === workspaceName)[0];
if (folder) {
return vscode.Uri.file(pathUtils.join(folder.uri.fsPath, workspacePath));
return uriFromFolderWithPath(folder, workspacePath);
}
}
else if (vscode.workspace.workspaceFolders.length === 1) {
return vscode.Uri.file(pathUtils.join(vscode.workspace.workspaceFolders[0].uri.fsPath, path));
return uriFromFolderWithPath(vscode.workspace.workspaceFolders[0], path);
} else if (resultsUri.scheme !== 'untitled') {
// We're in a multi-root workspace, but the path is not multi-root formatted
// Possibly a saved search from a single root session. Try checking if the search result document's URI is in a current workspace folder.
const prefixMatch = vscode.workspace.workspaceFolders.filter(wf => resultsUri.toString().startsWith(wf.uri.toString()))[0];
if (prefixMatch) { return vscode.Uri.file(pathUtils.join(prefixMatch.uri.fsPath, path)); }
if (prefixMatch) {
return uriFromFolderWithPath(prefixMatch, path);
}
}
}