Skip to content

Commit

Permalink
Support hack root in an arbitrary subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfootjon committed Mar 29, 2021
1 parent 94036a2 commit d631410
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@
"default": "hh_client",
"description": "Absolute path to the hh_client executable. This can be left empty if hh_client is already in your environment $PATH."
},
"hack.rootPath": {
"type": "string",
"default": "",
"description": "Relative path to the directory containing .hhconfig"
},
"hack.workspaceRootPath": {
"type": "string",
"default": null,
Expand Down Expand Up @@ -311,7 +316,7 @@
]
},
"activationEvents": [
"workspaceContains:.hhconfig",
"workspaceContains:**/.hhconfig",
"onDebug"
],
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const hackConfig = vscode.workspace.getConfiguration("hack");
// tslint:disable-next-line:no-non-null-assertion
export const localWorkspacePath = vscode.workspace.workspaceFolders![0].uri
.fsPath;
export const workspaceRelativeRootPath = hackConfig.get<string>("rootPath") || "";

export let clientPath = hackConfig.get<string>("clientPath") || "hh_client";
clientPath = clientPath.replace("${workspaceFolder}", localWorkspacePath);
Expand Down
9 changes: 4 additions & 5 deletions src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import * as config from "./Config";
* @param includeScheme Whether to include the file:// scheme in the response or not
*/
export const mapFromWorkspaceUri = (file: vscode.Uri): string => {
if (!config.remoteEnabled || !config.remoteWorkspacePath) {
return file.toString();
let workspaceRoot = file.toString()
if (config.remoteEnabled && config.remoteWorkspacePath) {
workspaceRoot = workspaceRoot.replace(config.localWorkspacePath, config.remoteWorkspacePath);
}
return file
.toString()
.replace(config.localWorkspacePath, config.remoteWorkspacePath);
return workspaceRoot + "/" + config.workspaceRelativeRootPath;
};

/**
Expand Down

0 comments on commit d631410

Please sign in to comment.