Skip to content

Commit 3041e9a

Browse files
author
Tim Etchells
committed
Fix workspace lacking drive letter on windows
Fixes #25
1 parent 938b87b commit 3041e9a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

dev/src/command/NewConnectionCmd.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,29 @@ export async function onSuccessfulConnection(mcUri: vscode.Uri, host: string, mc
181181

182182
const rawVersion: string = mcEnvData.microclimate_version;
183183
const rawWorkspace: string = mcEnvData.workspace_location;
184+
const rawPlatform: string = mcEnvData.os_platform;
184185

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

194+
let workspace = rawWorkspace;
195+
// on windows, we have to replace the unix-like workspace path with a windows one. /C/Users/... -> C:/Users/ ...
196+
// logic copied from Eclipse plugin
197+
// MicroclimateConnection.java#L244
198+
if (rawPlatform.toLowerCase() === "windows" && workspace.startsWith("/")) {
199+
const deviceLetter = workspace.substring(1, 2);
200+
workspace = deviceLetter + ":" + workspace.substring(2);
201+
}
202+
192203
const versionNum = MCEnvironment.getVersionNumber(mcEnvData);
193204

194205
try {
195-
return await ConnectionManager.instance.addConnection(mcUri, host, versionNum, rawWorkspace);
206+
return await ConnectionManager.instance.addConnection(mcUri, host, versionNum, workspace);
196207
}
197208
catch (err) {
198209
Log.i("New connection rejected by ConnectionManager ", err.message || err);

dev/src/microclimate/connection/MCEnvironment.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace MCEnvironment {
2828
devops_available: boolean;
2929
editor_url: string;
3030
microclimate_version: string;
31+
os_platform: string;
3132
running_on_icp: boolean;
3233
socket_namespace?: string;
3334
user_string?: string;
@@ -96,7 +97,7 @@ namespace MCEnvironment {
9697
else {
9798
const year = Math.floor(versionNum / 100);
9899
const month = versionNum % 100;
99-
return `${year}.${month}`;
100+
return `${year}.${month < 10 ? "0" + month : month}`;
100101
}
101102
}
102103

0 commit comments

Comments
 (0)