golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.91k stars 758 forks source link

Show strings with newlines across multiple lines in debugger #3592

Open mtaran opened 3 weeks ago

mtaran commented 3 weeks ago

Is your feature request related to a problem? Please describe. I'm always frustrated when I am debugging and want to look at some multi-line input, but only get to see it squished to a single line with explicit \ns in it.

Describe the solution you'd like I would like either a user preference for whether to escape newlines or not, or for them to be shown in escaped/unescaped forms in different parts of the UI, e.g. in the variables panel vs. on hover. Right now all the UIs show them with explicit \ns.

Describe alternatives you've considered It would also be fine if I could use the debug console to print out the string, turning \ns into newlines. But call fmt.Println(...) errors out, and I couldn't find some alternative that would actually unescape the newlines.

Additional context https://github.com/golang/vscode-go/issues/1321 asked for the current behavior, but really the escaped/unescaped forms are useful in different contexts, so it'd be nice to have easy access to them both.

firelizzard18 commented 2 weeks ago

This is a delve issue. Unless you're using the legacy adapter, vscode-go does not control the presentation of variables. If delve adds a flag to control this behavior (whether to escape newlines/etc), vscode-go can add a setting to set that flag.

h9jiang commented 1 week ago

Hi mtaran, thanks for raising this issue. I believe firelizzard18 is correct. Thanks firelizzard18.

VSCode-Go delegates the debugging functionality via DAP to delv. VSCode-Go is responsible of figuring out the right configuration to delv and launching delv for debugging session.

From VSCode-Go side, we can certainly add a configuration field and pass this field eventually to delv to reach your desired behavior.

image