Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add openFilePath config; fix the bug when the server has more than on… #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions adapters/config-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var format = function (element){
"project": element.project, // Used for fast button (can be undefined)
"path": element.path, // Used for `cd` after start session (can be undefined)
"customCommands": element.customCommands, // Used for specify commands which will execute on session start
"openFilePath": element.openFilePath,
};
return config;
}
Expand Down
22 changes: 19 additions & 3 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ function openSSHConnection(serverName, isFastConnection, forwardingArgs = null)
else { // If the terminal instance was found
terminal = terminal.terminal;
terminalIsNew = false;
if (vscode.workspace.getConfiguration('sshextension').openProjectCatalog) {
if (isFastConnection)
terminal.sendText("cd " + fastOpenConnectionProjectPath);
}
}
if (!hasErrors) {
terminal.show();
Expand Down Expand Up @@ -283,6 +287,7 @@ function createForwarding(serverName){
// This method try to find server with project that contains file
function getProjectByFilePath(filePath) {
var projectPath = null;
var fileFolder = "";
// Get path to edited file with fixed drive letter case
var openedFileName = upath.normalize(filePath);
openedFileName = openedFileName.replace(/\w:/g, function (g) { return g.toLowerCase() })
Expand All @@ -295,14 +300,25 @@ function getProjectByFilePath(filePath) {
// Get project path with fixed drive letter case
var serverProjectPath = upath.normalize(item);
serverProjectPath = serverProjectPath.replace(/\w:/g, function (g) { return g.toLowerCase() });
thisServerMapped = isPathInside(openedFileName, serverProjectPath);
if (thisServerMapped) {
var isMapped = isPathInside(openedFileName, serverProjectPath);
if (isMapped) {
thisServerMapped = isMapped;
projectPath = element.configuration.project[item];
fileFolder = "";
if (openedFileName.length > serverProjectPath.length) {
fileFolder = openedFileName.substr(serverProjectPath.length, openedFileName.length - serverProjectPath.length);
fileFolder = fileFolder.substr(0, fileFolder.lastIndexOf('/'));
}
}
}, this);
return thisServerMapped;
}, openedFileName);
return { "server" : server, "projectPath" : projectPath };

var openPath = projectPath;
if (server && server.configuration.openFilePath) {
openPath = projectPath + fileFolder;
}
return { "server": server, "projectPath": openPath };
}

function manageFastOpenConnectionButtonState() {
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@
"type": "string",
"description": "Path on server for `cd` command after session start (not required)",
"required": false
},
},
"openFilePath": {
"type": "boolean",
"default": false,
"description": "Open File Direcotry"
},
"customCommands": {
"type": [
"array"
Expand Down