-
Notifications
You must be signed in to change notification settings - Fork 761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debug: Newlines in strings in debugger displayed as actual new lines instead of "\n" #1321
Comments
Thanks for the report @mattwelke We are currently working on a new debug adapter (that's embedded in |
@hyangah Sure I'll test that out. I'm not familiar with building things like that from scratch though so it might take me a bit to get it running. I'll post back when I do. Another thought I just had though is that maybe some folks would prefer the new lines not be escaped. Like my example where I mouse over the variable get a nice visual representation of it, with new lines rendered. Perhaps long term, the best option would be a toggle people could click on in the UI (maybe on the left, in the debugging section) where they could toggle escaping whitespace characters like new lines? |
According to DAP spec, What the new dlv-dap mode does is consistent with what dlv cli does:
A toggling option would have to be supported by both vscode UI (to get user input) and Debug Adapter Protocol (to communicate user setting to the adapter/debugger) for us to reconfigure this on the fly. I guess we could add a flag to launch.json configuration to configure this once for the duration of the session. |
Btw, there are many related vscode issues, which link to more related issues and discussions. See especially microsoft/vscode#73845, which "changed that VS Code debugger to no longer escape whitespaces." |
Since the new dlv dap mode escapes \n already, I propose to close this issue. |
Sorry I've been busy lately and never got around to trying the suggestions here to see if the new debugging stuff would work better. Is the conclusion here that the new debugging stuff will solve the DX problem I encountered by showing newline characters (literally |
This is what things look like with experimental dlv-dap adapter: |
That's brilliant. Thanks. :) |
Please answer these questions before submitting your issue. Thanks!
What version of Go, VS Code & VS Code Go extension are you using?
go version
to get version of Go from the VS Code integrated terminal.go version go1.16 linux/amd64
gopls -v version
to get version of Gopls from the VS Code integrated terminal.golang.org/x/tools/gopls v0.6.6
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.1.54.1
v0.23.2
Go: Locate Configured Go Tools
commandShare the Go related settings you have added/edited
Run
Preferences: Open Settings (JSON)
command to open your settings.json file.Share all the settings with the
go.
or["go"]
orgopls
prefixes.(none)
Describe the bug
When using the debugger, string values are rendered with newlines becoming actual newlines (preventing the characters after the newline from appearing). Example:
If I add a break point to the line with
fmt.Printf
, and observe the value oflongString
in the debugger, it appears like this:This isn't a useful way to see this information. For use cases like a JSON string, there will never be any useful information available to me for objects and arrays. In my opinion, it would be more useful to have the newlines converted to
\n
in this display, so that I can at least see more data from the string.I can se the rest of the string by moving my mouse over it, but this isn't as useful as just being able to see it at a glance, and makes it impossible to see the values for more than one string variable at a time that is like this:
Repo with full reproduction: https://github.com/mattwelke/go-string-with-newline-debugger-bug
Steps to reproduce the behavior:
The text was updated successfully, but these errors were encountered: