Skip to content

Commit bf85a03

Browse files
committed
Add support for folder uris using folder-uris parameter
1 parent 173be66 commit bf85a03

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/vs/code/electron-main/windows.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ export class WindowsManager implements IWindowsMainService {
790790
}
791791

792792
// Extract paths: from CLI
793-
else if (openConfig.cli._.length > 0) {
793+
else if (openConfig.cli._.length > 0 || openConfig.cli['folder-uris']) {
794794
windowsToOpen = this.doExtractPathsFromCLI(openConfig.cli);
795795
isCommandLineOrAPICall = true;
796796
}
@@ -847,7 +847,20 @@ export class WindowsManager implements IWindowsMainService {
847847
}
848848

849849
private doExtractPathsFromCLI(cli: ParsedArgs): IPath[] {
850-
const pathsToOpen = arrays.coalesce(cli._.map(candidate => this.parsePath(candidate, { ignoreFileNotFound: true, gotoLineMode: cli.goto })));
850+
const pathsToOpen = [];
851+
852+
// folder uris
853+
if (cli['folder-uris']) {
854+
const arg = cli['folder-uris'];
855+
const folderUris: string[] = typeof arg === 'string' ? [arg] : arg;
856+
pathsToOpen.push(...arrays.coalesce(folderUris.map(candidate => this.parseUri(URI.parse(candidate), { ignoreFileNotFound: true, gotoLineMode: cli.goto }))));
857+
}
858+
859+
// folder or file paths
860+
if (cli._ && cli._.length) {
861+
pathsToOpen.push(...arrays.coalesce(cli._.map(candidate => this.parsePath(candidate, { ignoreFileNotFound: true, gotoLineMode: cli.goto }))));
862+
}
863+
851864
if (pathsToOpen.length > 0) {
852865
return pathsToOpen;
853866
}

src/vs/platform/environment/common/environment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
88
export interface ParsedArgs {
99
[arg: string]: any;
1010
_: string[];
11+
'folder-uris'?: string | string[];
1112
_urls?: string[];
1213
help?: boolean;
1314
version?: boolean;

0 commit comments

Comments
 (0)