You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support rendering numbers in variables list in hex #3940
Requested by @timsneath.. It would be useful to be able to view values in hex format in the variables view.
VS Code/DAP only work with strings so cannot provide formatting themselves, but the recommended way seems to be to contribute a context menu entry and handle it ourselves:
This might need both work in the DAP and the VS Code extension (I'm also unsure whether this interacts with the ValueFormat in DAP spec, or if that's still VS-only).
Also opened microsoft/vscode#148125, since there are comments suggesting there may be a plan to move to the DAP standard way (ValueFormat) which would be much better than having to have non-standard DAP work and extra commands in the VS Code extension. If it seems like that might happen soon, it might be worth waiting for - but otherwise a command/custom request in the meantime might be worthwhile.
Super! Yeah, VS proper has support for this as a debugger-wide setting (see last sentence of this section), so I was a little surprised to hear that it would require custom work at the extension level. Thrilled to see it on the backlog!
On Tue, Jan 24, 2023 at 7:09 PM Danny Tuppeny ***@***.***> wrote:
It doesn't seem like there's going to be any official support for this in
VS Code soon. I had a quick play around, and I think we can implement this
in the SDK DAP server using the spec'd mechanism (ValueFormat), and then
use some custom code in the VS Code extension to inject a value for this as
VS Code sends the request to the server.
It needs a small custom request so we can also trigger a refresh of
variables already being displayed, but that's relatively simple.
We can only support toggling all numbers together though:
[image: numbers_as_hex]
<https://user-images.githubusercontent.com/1078012/214345103-8f106915-d1d2-4bec-b3b2-07cb658f6eaa.gif>
We could have a context menu entry to make it easier to toggle this rather
than going into settings. Though I wonder if it should:
1. Just temporarily change the format and not persist
2. Persist in User Settings
3. Persist in current projects settings
I feel like 1 is probably best (but we keep the setting so you can set it
globally or per-workspace if you want). 3 is appealing, but it might be odd
if you don't already have a .vscode/settings.json and we create one when
you toggle this. @timsneath <https://github.com/timsneath> any opinions?
—
Reply to this email directly, view it on GitHub
<#3940 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARWL667Q4LIWM77TX6CPFDWT75EXANCNFSM5ULF724Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
In Visual Studio (proper), I think it's just a toggle.
A toggle that persists across IDE sessions, or just temporarily for the current IDE session?
They also let you set a custom format specifier in the watch window:
Oh, that's interesting. That could be done entirely in the debug adapter since it doesn't need any UI parts too (and lets you mix and match). We could probably support d, h, nq, though I'm not sure about the others. I don't think we could have any UI for this though so would rely on the users knowing they can use these (turns out we can't even add context menu entries for the Watch pane, only the Variables pane 😞 microsoft/vscode#150161)
I don't have easy access to Windows/VS to test atm - do you know if these specifiers carry down to expanded members? For example if you put ,h on the end of a List<Foo> and the Foo instances had int fields, would you expect them to be formatted as hex, or should it only apply to the top-level expression (meaning it's only useful on string/ints)?
Had a quick play with format specifiers, and I like how it works. It also cleaned up some existing code we already had to suppress quotes in Strings for some places (now they can just use the same formatter we use if we parse a format specifier).
I made the specifier carry down through the variable, so doing "myList,h" will apply the hex formatting for the values once expanded.
It still needs some tidying up (and I need to wire up some UI like context menu on the Variables pane to toggle without using the format specifiers), but I'll get to that soon and let you know when there's something you could try out if you want.
As always, I appreciate the suggestions (though sorry this one took so long.. I'd really hoped VS Code would get a better first-party impl for this).
On Wed, Jan 25, 2023 at 8:59 PM Danny Tuppeny ***@***.***> wrote:
Had a quick play with format specifiers, and I like how it works. It also
cleaned up some existing code we already had to suppress quotes in Strings
for some places (now they can just use the same formatter we use if we
parse a format specifier).
I made the specifier carry down through the variable, so doing "myList,h"
will apply the hex formatting for the values once expanded.
[image: Screenshot 2023-01-25 at 17 55 40]
<https://user-images.githubusercontent.com/1078012/214644124-105d7804-a6cb-4b99-b78f-9629d9dbc28a.png>
It still needs some tidying up (and I need to wire up some UI like context
menu on the Variables pane to toggle without using the format specifiers),
but I'll get to that soon and let you know when there's something you could
try out if you want.
As always, I appreciate the suggestions (though sorry this one took so
long.. I'd really hoped VS Code would get a better first-party impl for
this).
—
Reply to this email directly, view it on GitHub
<#3940 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARWL66Q5CIEDVCRFSSLUQDWUFSZBANCNFSM5ULF724Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
Sweet! Sorry -- I haven't had the chance to look at this over the last day
or two :)
lol, np - I see you've been busy 😄
The debug adapter part of both features have landed in the SDK (dart-lang/sdk@1ff357f, dart-lang/sdk@b1c44bf). Format specifiers will work for Dart (non-Flutter) as soon as you have an SDK with that second change.
Format specifiers working in Flutter, and the toggle that changes all values formats will need a little more work (a DDS release, rolled into Flutter, and the Dart-Code changes landed). I'll ping when they're all done should you wish to try it out (assuming you're on Flutter master and the Dart-Code pre-release channel).
This is done now. It requires both changes to the SDKs and the VS Code extension, so for most users on stable, it won't be available until the next stable SDK releases, so I've assigned this to a future milestone to show up in the release notes then.
However if you want to try it out now you can with:
Flutter master (from today or newer) or similar Dart bleeding-edge/dev from a few days ago or newer
Be opted-in to the new SDK DAPs ("dart.previewSdkDaps": true,)
The format specifiers supported are ,nq (no quotes), ,d (decimal), ,h (hex) and they apply down the variables. There's a context menu entry for Variables which toggles the dart.showDebuggerNumbersAsHex setting can set the default formatting to hex for Variables/Watch/Debug Console (only hex/decimal is supported here because that functionality uses a standard DAP format setting).
I may tweak the wording on this context menu though (maybe changing "in" to "as") because testing it now it feels odd. I was trying to make sure "show as decimal" didn't suggest it meant it would add a decimal point, but maybe that's less of a worry since nobody will ever see that entry unless they've toggled into Hex first, and then it's probably obvious what it means.
Activity
DanTup commentedon Apr 26, 2022
Also opened microsoft/vscode#148125, since there are comments suggesting there may be a plan to move to the DAP standard way (
ValueFormat) which would be much better than having to have non-standard DAP work and extra commands in the VS Code extension. If it seems like that might happen soon, it might be worth waiting for - but otherwise a command/custom request in the meantime might be worthwhile.timsneath commentedon Apr 26, 2022
Super! Yeah, VS proper has support for this as a debugger-wide setting (see last sentence of this section), so I was a little surprised to hear that it would require custom work at the extension level. Thrilled to see it on the backlog!
11 remaining items
timsneath commentedon Jan 24, 2023
DanTup commentedon Jan 24, 2023
A toggle that persists across IDE sessions, or just temporarily for the current IDE session?
Oh, that's interesting. That could be done entirely in the debug adapter since it doesn't need any UI parts too (and lets you mix and match). We could probably support
d,h,nq, though I'm not sure about the others. I don't think we could have any UI for this though so would rely on the users knowing they can use these (turns out we can't even add context menu entries for the Watch pane, only the Variables pane 😞 microsoft/vscode#150161)I don't have easy access to Windows/VS to test atm - do you know if these specifiers carry down to expanded members? For example if you put
,hon the end of aList<Foo>and theFooinstances hadintfields, would you expect them to be formatted as hex, or should it only apply to the top-level expression (meaning it's only useful on string/ints)?DanTup commentedon Jan 25, 2023
Had a quick play with format specifiers, and I like how it works. It also cleaned up some existing code we already had to suppress quotes in Strings for some places (now they can just use the same formatter we use if we parse a format specifier).
I made the specifier carry down through the variable, so doing "myList,h" will apply the hex formatting for the values once expanded.
It still needs some tidying up (and I need to wire up some UI like context menu on the Variables pane to toggle without using the format specifiers), but I'll get to that soon and let you know when there's something you could try out if you want.
As always, I appreciate the suggestions (though sorry this one took so long.. I'd really hoped VS Code would get a better first-party impl for this).
timsneath commentedon Jan 26, 2023
[dds/dap] Tidy up variables formatting and allow "format specifiers" …
DanTup commentedon Jan 26, 2023
lol, np - I see you've been busy 😄
The debug adapter part of both features have landed in the SDK (dart-lang/sdk@1ff357f, dart-lang/sdk@b1c44bf). Format specifiers will work for Dart (non-Flutter) as soon as you have an SDK with that second change.
Format specifiers working in Flutter, and the toggle that changes all values formats will need a little more work (a DDS release, rolled into Flutter, and the Dart-Code changes landed). I'll ping when they're all done should you wish to try it out (assuming you're on Flutter
masterand the Dart-Code pre-release channel).DanTup commentedon Jan 31, 2023
This is done now. It requires both changes to the SDKs and the VS Code extension, so for most users on stable, it won't be available until the next stable SDK releases, so I've assigned this to a future milestone to show up in the release notes then.
However if you want to try it out now you can with:
master(from today or newer) or similar Dart bleeding-edge/dev from a few days ago or newer"dart.previewSdkDaps": true,)The format specifiers supported are
,nq(no quotes),,d(decimal),,h(hex) and they apply down the variables. There's a context menu entry for Variables which toggles thedart.showDebuggerNumbersAsHexsetting can set the default formatting to hex for Variables/Watch/Debug Console (only hex/decimal is supported here because that functionality uses a standard DAP format setting).I may tweak the wording on this context menu though (maybe changing "in" to "as") because testing it now it feels odd. I was trying to make sure "show as decimal" didn't suggest it meant it would add a decimal point, but maybe that's less of a worry since nobody will ever see that entry unless they've toggled into Hex first, and then it's probably obvious what it means.
NeariX67 commentedon Jul 24, 2024
Does not work for Uint8List from
dart:typed_data.List<int>works fine.DanTup commentedon Jul 24, 2024
@NeariX67 I've opened #5199 about this