Skip to content

Commit

Permalink
Fix workspace lacking drive letter on windows
Browse files Browse the repository at this point in the history
Fixes #25
  • Loading branch information
Tim Etchells committed Jan 22, 2019
1 parent 938b87b commit 3041e9a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion dev/src/command/NewConnectionCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,29 @@ export async function onSuccessfulConnection(mcUri: vscode.Uri, host: string, mc

const rawVersion: string = mcEnvData.microclimate_version;
const rawWorkspace: string = mcEnvData.workspace_location;
const rawPlatform: string = mcEnvData.os_platform;

Log.d("rawVersion from Microclimate is", rawVersion);
Log.d("rawWorkspace from Microclimate is", rawWorkspace);
Log.d("rawPlatform from Microclimate is", rawPlatform);
if (rawVersion == null || rawWorkspace == null) {
Log.e("Microclimate environment did not provide either version or workspace. Data provided is:", mcEnvData);
throw new Error(Translator.t(STRING_NS, "versionNotProvided", { requiredVersion: MCEnvironment.REQUIRED_VERSION_STR }));
}

let workspace = rawWorkspace;
// on windows, we have to replace the unix-like workspace path with a windows one. /C/Users/... -> C:/Users/ ...
// logic copied from Eclipse plugin
// MicroclimateConnection.java#L244
if (rawPlatform.toLowerCase() === "windows" && workspace.startsWith("/")) {
const deviceLetter = workspace.substring(1, 2);
workspace = deviceLetter + ":" + workspace.substring(2);
}

const versionNum = MCEnvironment.getVersionNumber(mcEnvData);

try {
return await ConnectionManager.instance.addConnection(mcUri, host, versionNum, rawWorkspace);
return await ConnectionManager.instance.addConnection(mcUri, host, versionNum, workspace);
}
catch (err) {
Log.i("New connection rejected by ConnectionManager ", err.message || err);
Expand Down
3 changes: 2 additions & 1 deletion dev/src/microclimate/connection/MCEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace MCEnvironment {
devops_available: boolean;
editor_url: string;
microclimate_version: string;
os_platform: string;
running_on_icp: boolean;
socket_namespace?: string;
user_string?: string;
Expand Down Expand Up @@ -96,7 +97,7 @@ namespace MCEnvironment {
else {
const year = Math.floor(versionNum / 100);
const month = versionNum % 100;
return `${year}.${month}`;
return `${year}.${month < 10 ? "0" + month : month}`;
}
}

Expand Down

0 comments on commit 3041e9a

Please sign in to comment.