Skip to content

Commit

Permalink
sync: merge microsoft/vscode-go@d3c0757 into master
Browse files Browse the repository at this point in the history
Change-Id: I85b9ae1d9679d6a86065b162fe82e72bef91e392
  • Loading branch information
hyangah committed Apr 23, 2020
2 parents b06de5b + d3c0757 commit d538ccc
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,14 +843,29 @@ class GoDebugSession extends LoggingDebugSession {
return this.convertDebuggerPathToClient(pathToConvert);
}

// Fix for https://github.com/Microsoft/vscode-go/issues/1178
// When the pathToConvert is under GOROOT, replace the remote GOROOT with local GOROOT
// When the pathToConvert is under GOROOT or Go module cache, replace path appropriately
if (!pathToConvert.startsWith(this.delve.remotePath)) {
// Fix for https://github.com/Microsoft/vscode-go/issues/1178
const index = pathToConvert.indexOf(`${this.remotePathSeparator}src${this.remotePathSeparator}`);
const goroot = process.env['GOROOT'];
if (goroot && index > 0) {
return path.join(goroot, pathToConvert.substr(index));
}

const indexGoModCache = pathToConvert.indexOf(
`${this.remotePathSeparator}pkg${this.remotePathSeparator}mod${this.remotePathSeparator}`
);
const gopath = (process.env['GOPATH'] || '').split(path.delimiter)[0];

if (gopath && indexGoModCache > 0) {
return path.join(
gopath,
pathToConvert
.substr(indexGoModCache)
.split(this.remotePathSeparator)
.join(this.localPathSeparator)
);
}
}
return pathToConvert
.replace(this.delve.remotePath, this.delve.program)
Expand Down

0 comments on commit d538ccc

Please sign in to comment.