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

Commit

Permalink
Show map key value correctly in the variable pane #1384
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Feb 18, 2018
1 parent 72f79a7 commit 6cc51f2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ class GoDebugSession extends DebugSession {
verbose('VariablesRequest');
let vari = this._variableHandles.get(args.variablesReference);
let variables;
if (vari.kind === GoReflectKind.Array || vari.kind === GoReflectKind.Slice || vari.kind === GoReflectKind.Map) {
if (vari.kind === GoReflectKind.Array || vari.kind === GoReflectKind.Slice) {
variables = vari.children.map((v, i) => {
let { result, variablesReference } = this.convertDebugVariableToProtocolVariable(v, i);
return {
Expand All @@ -724,6 +724,20 @@ class GoDebugSession extends DebugSession {
variablesReference
};
});
} else if (vari.kind === GoReflectKind.Map) {
variables = [];
for (let i = 0; i < vari.children.length; i += 2) {
if (i + 1 >= vari.children.length) {
break;
}
let mapKey = this.convertDebugVariableToProtocolVariable(vari.children[i], i);
let mapValue = this.convertDebugVariableToProtocolVariable(vari.children[i + 1], i + 1);
variables.push({
name: mapKey.result,
value: mapValue.result,
variablesReference: mapValue.variablesReference
});
}
} else {
variables = vari.children.map((v, i) => {
let { result, variablesReference } = this.convertDebugVariableToProtocolVariable(v, i);
Expand Down

0 comments on commit 6cc51f2

Please sign in to comment.