Skip to content

Support rendering numbers in variables list in hex #3940

Closed

Description

@DanTup

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:

microsoft/vscode#28025 (comment)

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).

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    in debuggingRelates to the debug adapter or process of running debug sessions
    on Apr 26, 2022
  2. modified the milestones: On Deck, v3.42.0 on Apr 26, 2022
  3. DanTup commented on Apr 26, 2022

    @DanTup
    MemberAuthor

    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.

  4. timsneath commented on Apr 26, 2022

    @timsneath
    Contributor

    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!

  5. modified the milestones: v3.42.0, v3.44.0 on May 25, 2022
  6. modified the milestones: v3.44.0, v3.46.0 on Jun 30, 2022
  7. modified the milestones: v3.46.0, v3.48.0 on Jul 26, 2022
  8. modified the milestones: v3.48.0, v3.50.0 on Aug 25, 2022
  9. 11 remaining items

  10. timsneath commented on Jan 24, 2023

    @timsneath
    Contributor
  11. DanTup commented on Jan 24, 2023

    @DanTup
    MemberAuthor

    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)?

  12. DanTup commented on Jan 25, 2023

    @DanTup
    MemberAuthor

    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.

    Screenshot 2023-01-25 at 17 55 40

    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).

  13. timsneath commented on Jan 26, 2023

    @timsneath
    Contributor
  14. DanTup commented on Jan 26, 2023

    @DanTup
    MemberAuthor

    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).

  15. DanTup commented on Jan 31, 2023

    @DanTup
    MemberAuthor

    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 on the Pre-Release version of the Dart extension
    • 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).

    Jan-31-2023 16-56-13

    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.

  16. added
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    on May 2, 2023
  17. NeariX67 commented on Jul 24, 2024

    @NeariX67

    Does not work for Uint8List from dart:typed_data. List<int> works fine.

  18. DanTup commented on Jul 24, 2024

    @DanTup
    MemberAuthor

    @NeariX67 I've opened #5199 about this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in debuggingRelates to the debug adapter or process of running debug sessionsis enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions