-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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 console: '\n' not shown as new line for evaluation returning a variablesReference #73845
Comments
This is not an issue with VSCode. You have a new line inside a Python list. If you want each item in the list on a new line you need to use a loop and print out each line followed by the new line character. |
I don't get the point. It is a numpy ndarray (not Python list).
|
\n
not shown as new line\n
not shown as new line (NumPy ndarray)
Possibly an issue for the Python extension? |
This issue is caused by an extension, please file it with the repository (or contact) the extension has linked in its overview in VS Code or the marketplace for VS Code. See also our issue reporting guidelines. Happy Coding! |
What seems to be happening is that in the case where an expression is evaluated and returns a Some more info from the debugger backend: Given the following Python code (not using numpy to make it simpler):
Pausing at the breakpoint and sending
and the response is:
So, you can see that the result has proper new lines and So, this would be a request (and not a bug since it seems it's deliberately doing the same thing done in the variables view) for As a note, if |
A better title for this issue is probably:
-- note that if |
\n
not shown as new line (NumPy ndarray)
I pushed a fix for this. Please try it out in monday's vscode insiders and let me know if it behaves better for you. Thanks |
In my opinion, the initial behavior with the newline characters escaped is the correct one because that value is just a (one-liner preferably) preview representation of a composite object that you can click to expand the tree node. Also I could argue that the output from the repl in the terminal doesn't need to match the output in the debug console for example in node: > Array.from({length: 10}, () => Array.from({length: 5}, () => Math.floor(Math.random() * 100)))
[ [ 39, 42, 89, 80, 35 ],
[ 59, 34, 2, 99, 30 ],
[ 48, 15, 39, 73, 91 ],
[ 77, 27, 14, 52, 87 ],
[ 87, 68, 69, 98, 54 ],
[ 18, 55, 87, 90, 82 ],
[ 13, 82, 74, 62, 65 ],
[ 59, 62, 67, 65, 4 ],
[ 31, 99, 56, 45, 38 ],
[ 35, 22, 84, 66, 13 ] ] So I think this should be fixed in the python extension. |
As a note, in the Python extension the user could already see inside as a structured object as you're doing in node (so, there's nothing to actually be fixed in the Python extension, that behavior already existed), and if it wasn't a structured object then it'd already appear in multiple lines. I think it's more about expectations... when using an interactive console in Python users are used to see things printed (so, in the terminal using Python interactively if you wanted to see the Now, this change empowers extensions to do as they please (if the node plugin wants, they can show the actual I personally prefer the current version instead of having to click through to see things in the terminal, but I also agree it's pretty much a matter of personal taste. |
I agree its a matter of taste, but I have a few observations:
So I think we should print variable values following 1 or 2 but not mixing both. |
Both points are valid. And yes we were inspired by the chrome dev tools console. |
Thank you for all the discussion. (Sorry for being late to reply) However, it is sad to see this change being reverted. We were in the right direction—Let the extension determine what to show (i.e. the The original motivation for the escape is "we use
Next, I will address the specific concerns mentioned above. Previously
|
From a practical point of view, it's vary hard to inspect the python data science structures from Python encourages for these things to produce formatted strings to be more human readable, which these libraries do. So even if it's decided that it's best that the debug console not allow this, there should be some way to get to this representation in a VSCode debug session. Have even tried to print(my_array) and switching to the terminal tab to try and get some clue as to the shape of these data structures. This feature: https://github.com/microsoft/vscode-python/issues/5113 may end up solving this, but I don't believe it is currently possible to use this in debug or would be available that soon. Mainly feel that leaving it to the extension to decide, as mentioned above, so it can be done on a per-language basis would be great. And I think it does in python. Also, it is a pain point in using VSCode with these data science libraries and debugging data structures, when all you are looking for is if a matrix has values in the diagonal. So if the opposition to this is somewhat notional, I think the user experience here may trump that. Cheers. |
This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider. If you wonder what we are up to, please see our roadmap and issue reporting guidelines. Thanks for your understanding and happy coding! |
Clossing as out of scope. |
Maybe off-topic, but for those of us that want to pause the python debugger in VS Code and then pretty-print numpy arrays (or other expressions containing newlines required for legibility) from the debug console, one available work-around is to print the expression to a text file (which could conveniently be kept open for viewing in a separate editor pane). For example, to print numpy array variable
Or append to the end of the file:
|
Thank you very much for your feedback. After discussing with @weinand we came to the following conclusion: The VS Code frontend should not escape newlines. It is up to the debug extension to decide how the data should be presented and the debug extension can decide if a newline shuold be escaped or not. The downside of this approach is that in the Variables view the multine values will from now on only show the first line of the value. However it is up to the debug extensions to change their responses to escape new lines. Due to that we plan to make this change start of next milestone so extensions are given enough time to adopt. Thus reopening. We do not want to add a setting for this behavior as it does not feel right for the user to control this and adding a capability also requires adoption by extensions (a similar work as our escaping approach requires). @weinand please add more details or correct if I captured something wrongly from our discussion |
Thanks for the update. |
As announced in my previous comment we have changed that VS Code debugger is no longer escaping whitespaces. Now it is up to the debugger to handle this on their side. |
If a debugger decides to "escape" newlines here, won't it break the "Copy value" functionality? The user will then end up with a string with these characters escaped, rather than literal? |
@DanTup No, I do not think so. Since the copy value functionality invokes the |
@isidorn but the above text specifically mentions
In order to fix this, the DA needs to escape newlines to |
I agree that |
Issue Type: Bug
Type these code in the debug console
VS Code version: Code 1.33.1 (51b0b28, 2019-04-11T08:27:14.102Z)
OS version: Windows_NT x64 10.0.18898
System Info
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
Extensions (20)
The text was updated successfully, but these errors were encountered: