-
Notifications
You must be signed in to change notification settings - Fork 645
launch.json env option to display numbers as hex while debugging #1801
Conversation
…as hex together with the decimal value (i.e. 10 is displayed as 0x0a (10))
in launch.json: ... "env": { // controls numbers display while debugging // "hex" (shows hex only) "hexdec" ( shows hex (dec) ) // default: shows dec only "DBG_SHOW_NUMBERS_HEX": "hexdec" }, ...
Can you elaborate on some examples where this will be useful? |
hi ramya, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There have been times I've wanted this functionality (e.g. being able to view ACSII characters for structs marshalled to JSON), needs some clean-up before we can merge though.
@@ -519,6 +517,19 @@ class GoDebugSession extends DebugSession { | |||
if (/^(\w:[\\/]|\\\\)/.test(path)) return '\\'; | |||
return path.includes('/') ? '/' : '\\'; | |||
} | |||
protected convertToHex(v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sig should be private convertToHex(v: string): string
. Also missing a new-line character between 519 and 520.
return { | ||
result: v.value || ('<' + v.type + '>'), | ||
variablesReference: this._variableHandles.create(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect and will cause boolean types to display like they have child elements. It should remain variablesReference: v.children.length > 0 ? this._variableHandles.create(v) : 0
like below which means the two clauses can be refactored.
}; | ||
} else { | ||
return { | ||
result: this.convertToHex(v.value) || ('<' + v.type + '>'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For types v.value
will be an empty string, so convertToHex()
needs to handle this case and return an empty string (with the current implementation you get 0xNaN
in the variables window).
protected convertToHex(v) { | ||
let s = v; | ||
if (this.numAsHex === 'hex') { | ||
s = '0x' + parseInt(v).toString(16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will truncate floating-point numbers. Perhaps this functionality should be limited to integers?
Related microsoft/vscode#28025 |
@jhendrixMSFT Does microsoft/vscode#28025 (comment) work for Go? |
@ramya-rao-a no it doesn't work, would be great to fix it. |
Hello, is this PR still valid? |
Closing this PR as it has not seen any activity after the review by @jhendrixMSFT last year #1801 (review) If anyone is interested in reviving this PR, please create a new one in https://github.com/golang/vscode-go as we are moving the repo for this extension. |
wonder why this was missing.......