Skip to content

Commit

Permalink
web - only simplify vscode-remote workspaces (#141411)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Jan 25, 2022
1 parent a9ed79d commit 8d78843
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions src/vs/code/browser/workbench/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { request } from 'vs/base/parts/request/browser/request';
import product from 'vs/platform/product/common/product';
import { isFolderToOpen, isWorkspaceToOpen } from 'vs/platform/windows/common/windows';
import { create, ICredentialsProvider, IURLCallbackProvider, IWorkbenchConstructionOptions, IWorkspace, IWorkspaceProvider } from 'vs/workbench/workbench.web.main';
import { posix } from 'vs/base/common/path';
import { ltrim } from 'vs/base/common/strings';

interface ICredential {
service: string;
Expand Down Expand Up @@ -299,8 +301,11 @@ class WorkspaceProvider implements IWorkspaceProvider {

// Folder
case WorkspaceProvider.QUERY_PARAM_FOLDER:
if (config.remoteAuthority) {
workspace = { folderUri: URI.from({ scheme: 'vscode-remote', path: value, authority: config.remoteAuthority }) }; // support the nicer URI syntax for folders when connected to a remote
if (config.remoteAuthority && value.startsWith(posix.sep)) {
// when connected to a remote and having a value
// that is a path (begins with a `/`), assume this
// is a vscode-remote resource as simplified URL.
workspace = { folderUri: URI.from({ scheme: Schemas.vscodeRemote, path: value, authority: config.remoteAuthority }) };
} else {
workspace = { folderUri: URI.parse(value) };
}
Expand All @@ -309,8 +314,11 @@ class WorkspaceProvider implements IWorkspaceProvider {

// Workspace
case WorkspaceProvider.QUERY_PARAM_WORKSPACE:
if (config.remoteAuthority) {
workspace = { workspaceUri: URI.from({ scheme: 'vscode-remote', path: value, authority: config.remoteAuthority }) }; // support the nicer URI syntax for workspaces when connected to a remote
if (config.remoteAuthority && value.startsWith(posix.sep)) {
// when connected to a remote and having a value
// that is a path (begins with a `/`), assume this
// is a vscode-remote resource as simplified URL.
workspace = { workspaceUri: URI.from({ scheme: Schemas.vscodeRemote, path: value, authority: config.remoteAuthority }) };
} else {
workspace = { folderUri: URI.parse(value) };
}
Expand Down Expand Up @@ -412,8 +420,13 @@ class WorkspaceProvider implements IWorkspaceProvider {
// Folder
else if (isFolderToOpen(workspace)) {
let queryParamFolder: string;
if (this.config.remoteAuthority) {
queryParamFolder = workspace.folderUri.path; // prefer nicer, shorter URLs when connected to a remote to make opening local folders easier
if (this.config.remoteAuthority && workspace.folderUri.scheme === Schemas.vscodeRemote) {
// when connected to a remote and having a folder
// for that remote, only use the path as query
// value to form shorter, nicer URLs.
// ensure paths are absolute (begin with `/`)
// clipboard: ltrim(workspace.folderUri.path, posix.sep)
queryParamFolder = `${posix.sep}${ltrim(workspace.folderUri.path, posix.sep)}`;
} else {
queryParamFolder = encodeURIComponent(workspace.folderUri.toString(true));
}
Expand All @@ -424,8 +437,12 @@ class WorkspaceProvider implements IWorkspaceProvider {
// Workspace
else if (isWorkspaceToOpen(workspace)) {
let queryParamWorkspace: string;
if (this.config.remoteAuthority) {
queryParamWorkspace = workspace.workspaceUri.path; // prefer nicer, shorter URLs when connected to a remote to make opening local workspaces easier
if (this.config.remoteAuthority && workspace.workspaceUri.scheme === Schemas.vscodeRemote) {
// when connected to a remote and having a workspace
// for that remote, only use the path as query
// value to form shorter, nicer URLs.
// ensure paths are absolute (begin with `/`)
queryParamWorkspace = `${posix.sep}${ltrim(workspace.workspaceUri.path, posix.sep)}`;
} else {
queryParamWorkspace = encodeURIComponent(workspace.workspaceUri.toString(true));
}
Expand Down

0 comments on commit 8d78843

Please sign in to comment.