Skip to content

Commit

Permalink
Opening remote file from cli is opening folder. Fixes #85883
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Dec 1, 2019
1 parent 3295e51 commit f667462
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/vs/platform/windows/electron-main/windowsMainService.ts
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import * as fs from 'fs';
import { basename, normalize, join, } from 'vs/base/common/path';
import { basename, normalize, join, posix } from 'vs/base/common/path';
import { localize } from 'vs/nls';
import * as arrays from 'vs/base/common/arrays';
import { assign, mixin } from 'vs/base/common/objects';
Expand Down Expand Up @@ -1108,8 +1108,6 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
const remoteAuthority = options.remoteAuthority;

if (remoteAuthority) {
// assume it's a folder or workspace file

const first = anyPath.charCodeAt(0);
// make absolute
if (first !== CharCode.Slash) {
Expand All @@ -1121,11 +1119,15 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic

const uri = URI.from({ scheme: Schemas.vscodeRemote, authority: remoteAuthority, path: anyPath });

if (hasWorkspaceFileExtension(anyPath)) {
if (forceOpenWorkspaceAsFile) {
// guess the file type: If it ends with a slash it's a folder. If it has a file extension, it's a file or a workspace. By defaults it's a folder.
if (anyPath.charCodeAt(anyPath.length - 1) !== CharCode.Slash) {
if (hasWorkspaceFileExtension(anyPath)) {
if (forceOpenWorkspaceAsFile) {
return { fileUri: uri, remoteAuthority };
}
} else if (posix.extname(anyPath).length > 0) {
return { fileUri: uri, remoteAuthority };
}
return { workspace: getWorkspaceIdentifier(uri), remoteAuthority };
}
return { folderUri: uri, remoteAuthority };
}
Expand Down

0 comments on commit f667462

Please sign in to comment.