Skip to content

Commit 691af75

Browse files
committed
Add auto remote path from sftp config
1 parent 9258863 commit 691af75

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

vscode-plugin/src/config/defaultValues.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export class DefaultConfigValues {
2525
}
2626

2727
public static getDefaultRemotePath(): string {
28-
if (os.platform() === 'win32') {
29-
return "";
28+
if (Prefs.isRemoteScenario()) {
29+
return vsUtils.getRemotePathFromSftpConfig();
3030
} else {
3131
return vsUtils.getProjectDirByOpenedFile().fsPath;
3232
}

vscode-plugin/src/utils/vscodeUtils.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,18 @@ export function getTextEditor(): vs.TextEditor | undefined {
4848
}
4949
return undefined;
5050
}
51+
52+
export function getRemotePathFromSftpConfig(): string {
53+
let workspaceFolder = vs.workspace.workspaceFolders?.[0].uri.fsPath;
54+
if (workspaceFolder) {
55+
let sftpConfigPath = pathUtils.fsJoin(workspaceFolder, '.vscode', 'sftp.json');
56+
if (fs.existsSync(sftpConfigPath)) {
57+
let rawData = fs.readFileSync(sftpConfigPath);
58+
let configJson = JSON.parse(rawData.toString());
59+
if (configJson.remotePath) {
60+
return configJson.remotePath;
61+
}
62+
}
63+
}
64+
return "";
65+
}

0 commit comments

Comments
 (0)