From 105e87186fe8dc2ef60b9fb55254552ba1994f32 Mon Sep 17 00:00:00 2001 From: Andre Weinand Date: Wed, 17 Apr 2019 17:26:40 +0200 Subject: [PATCH] filter workspace paths contradicting ext development --- src/vs/code/electron-main/windows.ts | 76 +++++++++++++++++----------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index 9d2aa4ec4b0..7ade1ce6bde 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -1190,46 +1190,62 @@ export class WindowsManager implements IWindowsMainService { } } - // Make sure we are not asked to open a workspace or folder that is already opened - if (cliArgs.length && cliArgs.some(path => !!findWindowOnWorkspaceOrFolderUri(WindowsManager.WINDOWS, URI.file(path)))) { - cliArgs = []; + if (!Array.isArray(extensionDevelopmentPath)) { + extensionDevelopmentPath = [extensionDevelopmentPath]; } - if (folderUris.length && folderUris.some(uri => !!findWindowOnWorkspaceOrFolderUri(WindowsManager.WINDOWS, this.argToUri(uri)))) { - folderUris = []; - } - - if (fileUris.length && fileUris.some(uri => !!findWindowOnWorkspaceOrFolderUri(WindowsManager.WINDOWS, this.argToUri(uri)))) { - fileUris = []; - } - - openConfig.cli._ = cliArgs; - openConfig.cli['folder-uri'] = folderUris; - openConfig.cli['file-uri'] = fileUris; - - if (Array.isArray(extensionDevelopmentPath)) { - let authority: string | undefined = undefined; - for (let p of extensionDevelopmentPath) { - const match = p.match(/^vscode-remote:\/\/([^\/]+)/); - if (match) { - const auth = URI.parse(p).authority; + let authority = ''; + for (let p of extensionDevelopmentPath) { + if (p.match(/^[a-zA-Z][a-zA-Z0-9\+\-\.]+:/)) { + const url = URI.parse(p); + if (url.scheme === Schemas.vscodeRemote) { if (authority) { - if (auth !== authority) { - console.log('more than one authority'); + if (url.authority !== authority) { + this.logService.error('more than one extension development path authority'); } } else { - authority = auth; + authority = url.authority; } } } - if (authority) { - openConfig.cli['remote'] = authority; + } + + // Make sure that we do not try to open: + // - a workspace or folder that is already opened + // - a workspace or file that has a different authority as the extension development. + + cliArgs = cliArgs.filter(path => { + const uri = URI.file(path); + if (!!findWindowOnWorkspaceOrFolderUri(WindowsManager.WINDOWS, uri)) { + return false; } + return uri.authority === authority; + }); - } else { - const match = extensionDevelopmentPath.match(/^vscode-remote:\/\/([^\/]+)/); - if (match) { - openConfig.cli['remote'] = URI.parse(extensionDevelopmentPath).authority; + folderUris = folderUris.filter(uri => { + const u = this.argToUri(uri); + if (!!findWindowOnWorkspaceOrFolderUri(WindowsManager.WINDOWS, u)) { + return false; + } + return u ? u.authority === authority : false; + }); + + fileUris = fileUris.filter(uri => { + const u = this.argToUri(uri); + if (!!findWindowOnWorkspaceOrFolderUri(WindowsManager.WINDOWS, u)) { + return false; + } + return u ? u.authority === authority : false; + }); + + openConfig.cli._ = cliArgs; + openConfig.cli['folder-uri'] = folderUris; + openConfig.cli['file-uri'] = fileUris; + + // if there are no files or folders cli args left, use the "remote" cli argument + if (!cliArgs.length && !folderUris.length && !fileUris.length) { + if (authority) { + openConfig.cli.remote = authority; } } -- GitLab