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

Map remote goroot to local goroot #1179

Merged
merged 3 commits into from
Sep 1, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
Binary file modified Go-latest.vsix
Binary file not shown.
16 changes: 13 additions & 3 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,21 @@ class GoDebugSession extends DebugSession {
return path.replace(this.delve.program, this.delve.remotePath).split(this.localPathSeparator).join(this.remotePathSeparator);
}

protected toLocalPath(path: string): string {
protected toLocalPath(pathToConvert: string): string {
if (this.delve.remotePath.length === 0) {
return this.convertDebuggerPathToClient(path);
return this.convertDebuggerPathToClient(pathToConvert);
}
return path.replace(this.delve.remotePath, this.delve.program).split(this.remotePathSeparator).join(this.localPathSeparator);

// Fix for https://github.com/Microsoft/vscode-go/issues/1178
// When the pathToConvert is under GOROOT, replace the remote GOROOT with local GOROOT
if (!pathToConvert.startsWith(this.delve.remotePath)) {
let index = pathToConvert.indexOf('src');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to be /src/ in the goroot, right? It could match a different src, like /Users/src/goroot/src/...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to match /src/

let goroot = process.env['GOROOT'];
if (goroot) {
return path.join(goroot, ...pathToConvert.substr(index).split(this.remotePathSeparator));
}
}
return pathToConvert.replace(this.delve.remotePath, this.delve.program).split(this.remotePathSeparator).join(this.localPathSeparator);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use path.join above and .join(this.localPathSeparator); here, should it be the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.join uses the path separator for the local machine so it would be the same localPathSeparator
additionally it also takes care of trailing / at the end of goroot if there is any.

So if I do a split on the goroot, remove trailing / if it exists, then I can use .join(this.localPathSeparator)

}

protected setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse, args: DebugProtocol.SetBreakpointsArguments): void {
Expand Down