Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Develop #1

Merged
merged 7 commits into from
May 9, 2019
Merged
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
35 changes: 23 additions & 12 deletions src/debugger/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,29 +297,38 @@ class RubyDebugSession extends DebugSession {
return subPath && !subPath.startsWith('..') && !path.isAbsolute(subPath);
}

private getPathImplementation(absolutePath: string): any {
return path && path.posix.isAbsolute(absolutePath) ? path.posix : path.win32;
private getPathImplementation(pathToCheck: string): any {
if (pathToCheck) {
if (pathToCheck.indexOf(path.posix.sep) >= 0) {
return path.posix;
} else if (pathToCheck.indexOf(path.win32.sep) >= 0) {
return path.win32;
}
}

return path;
}

protected convertClientPathToDebugger(localPath: string): string {
if (this.debugMode === Mode.launch) {
return localPath;
}

let relativeLocalPath = path.relative(this.requestArguments.cwd, localPath)
let relativeLocalPath = path.relative(this.requestArguments.cwd, localPath);

if (!this.isSubPath(relativeLocalPath)) {
return localPath;
}

let remotePathImplementation = this.getPathImplementation(this.requestArguments.remoteWorkspaceRoot);
let remoteWorkspaceRoot =
this.requestArguments.remoteWorkspaceRoot || this.requestArguments.cwd;

let remotePathImplementation = this.getPathImplementation(remoteWorkspaceRoot);
let localPathImplementation = this.getPathImplementation(this.requestArguments.cwd);

let relativePath = remotePathImplementation.join.apply(
null,
[this.requestArguments.remoteWorkspaceRoot].concat(
relativeLocalPath.split(localPathImplementation.sep)
)
[remoteWorkspaceRoot].concat(relativeLocalPath.split(localPathImplementation.sep))
);

return relativePath;
Expand All @@ -330,20 +339,22 @@ class RubyDebugSession extends DebugSession {
return serverPath;
}

let remotePathImplementation = this.getPathImplementation(this.requestArguments.remoteWorkspaceRoot);
let remoteWorkspaceRoot =
this.requestArguments.remoteWorkspaceRoot || this.requestArguments.cwd;

let remotePathImplementation = this.getPathImplementation(remoteWorkspaceRoot);
let localPathImplementation = this.getPathImplementation(this.requestArguments.cwd);

let relativeRemotePath = remotePathImplementation.relative(this.requestArguments.remoteWorkspaceRoot, serverPath)
let relativeRemotePath = remotePathImplementation.relative(remoteWorkspaceRoot, serverPath);


if (!this.isSubPath(relativeRemotePath)) {
return serverPath;
}

let relativePath = localPathImplementation.join.apply(
null,
[this.requestArguments.cwd].concat(
relativeRemotePath.split(remotePathImplementation.sep)
)
[this.requestArguments.cwd].concat(relativeRemotePath.split(remotePathImplementation.sep))
);

return relativePath;
Expand Down