Skip to content

Commit

Permalink
do not support folder paths on windows as folder uris
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jul 24, 2018
1 parent 46f0f8b commit 32ecb99
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/vs/code/electron-main/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ export class WindowsManager implements IWindowsMainService {
if (cli['folder-uri'] && cli['folder-uri'].length) {
const arg = cli['folder-uri'];
const folderUris: string[] = typeof arg === 'string' ? [arg] : arg;
pathsToOpen.push(...arrays.coalesce(folderUris.map(candidate => this.parseUri(URI.parse(candidate), { ignoreFileNotFound: true, gotoLineMode: cli.goto }))));
pathsToOpen.push(...arrays.coalesce(folderUris.map(candidate => this.parseUri(this.parseFolderUriArg(candidate), { ignoreFileNotFound: true, gotoLineMode: cli.goto }))));
}

// folder or file paths
Expand Down Expand Up @@ -963,6 +963,14 @@ export class WindowsManager implements IWindowsMainService {
return restoreWindows;
}

private parseFolderUriArg(arg: string): URI {
// Do not support if user has passed folder path on Windows
if (isWindows && /^([a-z])\:(.*)$/i.test(arg)) {
return null;
}
return URI.parse(arg);
}

private parseUri(anyUri: URI, options?: { ignoreFileNotFound?: boolean, gotoLineMode?: boolean, forceOpenWorkspaceAsFile?: boolean; }): IPathToOpen {
if (!anyUri || !anyUri.scheme) {
return null;
Expand Down Expand Up @@ -1110,7 +1118,7 @@ export class WindowsManager implements IWindowsMainService {
if (openConfig.cli['folder-uri']) {
const arg = openConfig.cli['folder-uri'];
const folderUris: string[] = typeof arg === 'string' ? [arg] : arg;
if (folderUris.some(uri => !!findWindowOnWorkspaceOrFolderUri(WindowsManager.WINDOWS, URI.parse(uri)))) {
if (folderUris.some(uri => !!findWindowOnWorkspaceOrFolderUri(WindowsManager.WINDOWS, this.parseFolderUriArg(uri)))) {
openConfig.cli['folder-uri'] = [];
}
}
Expand Down

0 comments on commit 32ecb99

Please sign in to comment.