Skip to content

Commit 15bcce9

Browse files
skoroPranayAgarwal
andauthored
Fix workspace and remote path mapping (#137)
* Fix workspace and remote path mapping Fix path mapping on Windows environment. * Improve path mapping Co-authored-by: Pranay Agarwal <[email protected]>
1 parent 04e7d1e commit 15bcce9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Utils.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
import * as vscode from "vscode";
66
import * as config from "./Config";
77

8+
const localPath = getUriFilePath(config.localWorkspacePath);
9+
const remotePath = getUriFilePath(config.remoteWorkspacePath);
10+
11+
function getUriFilePath(path: string|undefined): string {
12+
return path ? vscode.Uri.file(path).toString() : '';
13+
}
14+
815
/**
916
* Converts a local workspace URI to a file path string (with or without scheme) to pass to
1017
* the typechecker. Path is mapped to an alternate workspace root if configured.
@@ -17,7 +24,7 @@ export const mapFromWorkspaceUri = (file: vscode.Uri): string => {
1724
}
1825
return file
1926
.toString()
20-
.replace(config.localWorkspacePath, config.remoteWorkspacePath);
27+
.replace(localPath, remotePath);
2128
};
2229

2330
/**
@@ -29,8 +36,8 @@ export const mapToWorkspaceUri = (file: string): vscode.Uri => {
2936
let filePath = file;
3037
if (config.remoteEnabled && config.remoteWorkspacePath) {
3138
filePath = filePath.replace(
32-
config.remoteWorkspacePath,
33-
config.localWorkspacePath
39+
remotePath,
40+
localPath
3441
);
3542
}
3643
if (filePath.startsWith("file://")) {

0 commit comments

Comments
 (0)