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

Commit

Permalink
Fix loading of child types (#2320)
Browse files Browse the repository at this point in the history
Per Delve documentation type names should be enclosed in quotes; this
fixes parsing of type names with e.g. '-' characters in them.
  • Loading branch information
jhendrixMSFT authored and ramya-rao-a committed Feb 15, 2019
1 parent 405fc59 commit e638ad7
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ class GoDebugSession extends LoggingDebugSession {
// expressions passed to loadChildren defined per https://github.com/derekparker/delve/blob/master/Documentation/api/ClientHowto.md#loading-more-of-a-variable
if (vari.kind === GoReflectKind.Array || vari.kind === GoReflectKind.Slice) {
variablesPromise = Promise.all(vari.children.map((v, i) => {
return loadChildren(`*(*${this.removeRepoFromTypeName(v.type)})(${v.addr})`, v).then((): DebugProtocol.Variable => {
return loadChildren(`*(*"${v.type}")(${v.addr})`, v).then((): DebugProtocol.Variable => {
let { result, variablesReference } = this.convertDebugVariableToProtocolVariable(v);
return {
name: '[' + i + ']',
Expand Down Expand Up @@ -1151,7 +1151,7 @@ class GoDebugSession extends LoggingDebugSession {
if (v.fullyQualifiedName === undefined) {
v.fullyQualifiedName = vari.fullyQualifiedName + '.' + v.name;
}
return loadChildren(`*(*${this.removeRepoFromTypeName(v.type)})(${v.addr})`, v).then((): DebugProtocol.Variable => {
return loadChildren(`*(*"${v.type}")(${v.addr})`, v).then((): DebugProtocol.Variable => {
let { result, variablesReference } = this.convertDebugVariableToProtocolVariable(v);
return {
name: v.name,
Expand All @@ -1169,16 +1169,6 @@ class GoDebugSession extends LoggingDebugSession {
});
}

// removes all parts of the repo path from a type name.
// e.g. github.com/some/repo/package.TypeName becomes package.TypeName
private removeRepoFromTypeName(typeName: string): string {
const i = typeName.lastIndexOf('/');
if (i === -1) {
return typeName;
}
return typeName.substr(i + 1);
}

private cleanupHandles(): void {
this._variableHandles.reset();
this.stackFrameHandles.reset();
Expand Down

0 comments on commit e638ad7

Please sign in to comment.