Steps to Reproduce:
No matter what I try, I cannot get the variable's value into clip board. I even tried a screen grab, but the hoover window disappeared. I remember this feature from visual studio years ago. It is quite useful.
In the following gif you can see me doing this action in 3 different ways
I think one of these should work for you. Let me know if none work and I can reopen the issue.
Note that the last way is simple double click on variable to open the input box
Thanks for the short video. I didn't realize there was a copy value command. That is a handy option.
I should clarify that I wish for an advanced variable copy feature. For example,inspecting complex data like arrays or multi-field objects. Copying the variable value within the debugger is limited to about 43 characters and appears like this Array[46] [Array[2], Array[2], Array[2] 鈥
. I can go to an element within the object/array and if it is small enough copy that.
The feature as it is now works for single values or with very simple multiple field objects. However, although I can see full array/object in the debugger, I cannot copy them.
Got it, reopening and marking as a feature request
Add JSON.stringify(...)
to watch, then copy
how about an object, who's got many sub objects? The "Copy Value" option isn't there. Is there any way this can be done?
@omartin2010 https://github.com/Microsoft/vscode/issues/27950#issuecomment-420232186
I should have mentioned in the case of Python, which is what I'm using, I'm not seeing that json stringify function part of the json module, and also if I try to do a json.dump(myobj), my object isn't actually a json object so it's not serializable. Any easy alternative, short of using pickle.dumps(myobj)?
any suggestion for those that work with other languages?
I would like this functionality for PHP
@anubhav756 Slick!
Is there a way to get the full serialized representation of the value via 'Copy Value' action -- instead of the super truncated聽one ...?
JSON.stringify
It doesn't work. Says _error evaluating code_. It is tested with drupal variables.
pretty pretty please, request for php as well, driving me nuts :crab:
update.
var_export($wrapper, true) , seems to something similar, but it cuts off , like a string limit or something
@omartin2010
I am not sure what kind of object you are working with, but I was trying to copy all of the values from a specific column in a Pandas DataFrame when I stumbled upon this issue. I am running vscode 1.14.1 in a Conda Python environment.
It turned out that the output limitation wasn't due to the Debug Console's abilities, but actually stemmed from a setting in pandas. Specifically, I issued pandas.set_option('display.max_rows', None)
and then tried to print my DataFrame again and wuala. I could copy all 20055 output values directly from the console.
Feature request. Please add "Copy expanded value" to Debug Variables context menu.
@isidorn are we now using "evaluate" for simple and structured values?
So now every debug extension can now implement a "formatted deep copy" for structured objects by returning the string result of a JSON.stringify(...)
(or equivalent) from evaluate
if the context
argument has the value clipboard
, correct?
You are correct I believe.
Also the extension would have to set the following capability supportsClipboardContext
.
@isidorn then we should ask debug extension authors to adopt that approach, right?
We could start with js-debug and python...
@connor4312 @roblourens your opinion?
@weinand yes. @connor4312 could try it out and let us know how it feels in practice :)
Using "evaluate" for this feels weird, it's more of a formatting operation. Really dumb case, if this is supported in watches, and I have a watch for Math.random()
, and I copy it, I expect to get that exact value and not a value from evaluating the expression a second time right?
@roblourens valid point, but the implementation of evaluate
is free to just use formatting in the "context=clipboard" case.
I've implemented this in js-debug, it works well. Definitely a big QoL improvement, getting truncated values in copied expressions was quite annoying 馃檪
@connor4312 very very cool!
@weinand should I ping other debug authors so we get more extensions implementing this?
@isidorn yes, please ping the "usual suspects".
Dear Debug extension authors,
Now it is possible to implement advanced copy variable values for your debugger:
supportsClipboardContext
evaluate
call you should check if the context is 'clipboard'
, if yes that means the user is triggering the Copy Value
command and you can return the result of the "advanced copy" - a fully serialized value of the evaluationExample how @connor4312 has done it for js-debug https://github.com/microsoft/vscode-js-debug/commit/a136ba50faf501594a558ba78bb0ed0d13f84177
And in the gif above you can see how it works in practice.
Try it out and let us know how it goes. Thanks!
@APerricone, @akaroml, @andysterland, @ayuckhulk, @DanTup, @daviwil, @devoncarew, @dibyendumajumdar, @DonJayamanne, @felixfbecker, @glennsarti, @gregg-miskelly, @hbenl, @iradul, @ivanbuhov, @joelday, @jpogran, @joshtynjala, @Kode, @miniwolf, @MSLaguana, @luabud, @lukaszunity, @ntotten, @phoityne, @pieandcakes, @ptrthomas, @raix, @richterger, @rkeithhill, @rebornix, @roblourens, @svaarala, @testforstephen, @vadimcn, @vshaxe, @WebFreak001, @weinand, @yurydelendik
@isidorn seems to work for me - I was able to resolve https://github.com/Dart-Code/Dart-Code/issues/1990 with it. Thanks!
This feature is great. Thank you soo much :)
Since this can now be done by the debug extensions closing this.
Most helpful comment
Add
JSON.stringify(...)
to watch, then copy