Skip to content
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

Advanced copy variable values in debugger #27950

Closed
boardofchris opened this issue Jun 2, 2017 · 30 comments
Closed

Advanced copy variable values in debugger #27950

boardofchris opened this issue Jun 2, 2017 · 30 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality
Milestone

Comments

@boardofchris
Copy link

  • VSCode Version: 1.1.2.2
  • OS Version: macos

Steps to Reproduce:

  1. Run the debugger, set a break point (I am using Node, but assume it applies to all languages)
  2. Examine a variable's value in the variable debugger window or by hoovering over the variable name.
  3. Try to copy a variable's value so you can paste to notepad for future reference.
  4. 8(

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.

@isidorn isidorn added this to the June 2017 milestone Jun 6, 2017
@isidorn isidorn added the debug Debug viewlet, configurations, breakpoints, adapter issues label Jun 6, 2017
@isidorn
Copy link
Contributor

isidorn commented Jun 9, 2017

In the following gif you can see me doing this action in 3 different ways
copy

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

@isidorn isidorn closed this as completed Jun 9, 2017
@boardofchris
Copy link
Author

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.

@isidorn
Copy link
Contributor

isidorn commented Jun 9, 2017

Got it, reopening and marking as a feature request

@isidorn isidorn reopened this Jun 9, 2017
@isidorn isidorn added the feature-request Request for new features or functionality label Jun 9, 2017
@isidorn isidorn changed the title Copy variable values in debugger Advanced copy variable values in debugger Jun 9, 2017
@isidorn isidorn modified the milestones: Backlog, June 2017 Jun 9, 2017
@isidorn isidorn removed their assignment Jun 9, 2017
@anubhav756
Copy link

anubhav756 commented Sep 11, 2018

Add JSON.stringify(...) to watch, then copy

screenshot from 2018-09-11 16-23-11

@omartin2010
Copy link

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?

@anubhav756
Copy link

anubhav756 commented Sep 12, 2018

@omartin2010
Copy link

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

@LC43
Copy link

LC43 commented Dec 12, 2018

any suggestion for those that work with other languages?

@danielbeeke
Copy link

I would like this functionality for PHP

@ThomasGHenry
Copy link

@anubhav756 Slick!

@breathe
Copy link

breathe commented Jul 3, 2019

Is there a way to get the full serialized representation of the value via 'Copy Value' action -- instead of the super truncated one ...?

@perarg
Copy link

perarg commented Jul 27, 2019

JSON.stringify

It doesn't work. Says error evaluating code. It is tested with drupal variables.

@Sigtechnica
Copy link

Sigtechnica commented Sep 4, 2019

pretty pretty please, request for php as well, driving me nuts 🦀

update.
var_export($wrapper, true) , seems to something similar, but it cuts off , like a string limit or something

@digiwang
Copy link

digiwang commented Feb 8, 2020

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

@awoz
Copy link

awoz commented Apr 1, 2020

Feature request. Please add "Copy expanded value" to Debug Variables context menu.

@weinand
Copy link
Contributor

weinand commented Apr 7, 2020

@isidorn are we now using "evaluate" for simple and structured values?

@isidorn
Copy link
Contributor

isidorn commented Apr 7, 2020

@weinand yes. Code pointer

const evaluation = await session.evaluate(toEvaluate, stackFrame.frameId, context);

@weinand
Copy link
Contributor

weinand commented Apr 7, 2020

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?

@isidorn
Copy link
Contributor

isidorn commented Apr 7, 2020

You are correct I believe.
Also the extension would have to set the following capability supportsClipboardContext.

@weinand
Copy link
Contributor

weinand commented Apr 7, 2020

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

@isidorn
Copy link
Contributor

isidorn commented Apr 7, 2020

@weinand yes. @connor4312 could try it out and let us know how it feels in practice :)

@roblourens
Copy link
Member

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?

@weinand
Copy link
Contributor

weinand commented Apr 8, 2020

@roblourens valid point, but the implementation of evaluate is free to just use formatting in the "context=clipboard" case.

@connor4312
Copy link
Member

I've implemented this in js-debug, it works well. Definitely a big QoL improvement, getting truncated values in copied expressions was quite annoying 🙂

@isidorn
Copy link
Contributor

isidorn commented Apr 8, 2020

@connor4312 very very cool!
@weinand should I ping other debug authors so we get more extensions implementing this?

@weinand
Copy link
Contributor

weinand commented Apr 14, 2020

@isidorn yes, please ping the "usual suspects".

@isidorn
Copy link
Contributor

isidorn commented Apr 14, 2020

Dear Debug extension authors,

Now it is possible to implement advanced copy variable values for your debugger:

  1. Your extension needs to send the capability supportsClipboardContext
  2. In the 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 evaluation

Example how @connor4312 has done it for js-debug microsoft/vscode-js-debug@a136ba5
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

@DanTup
Copy link
Contributor

DanTup commented Apr 14, 2020

@isidorn seems to work for me - I was able to resolve Dart-Code/Dart-Code#1990 with it. Thanks!

@miniwolf
Copy link

This feature is great. Thank you soo much :)

@isidorn
Copy link
Contributor

isidorn commented Sep 10, 2020

Since this can now be done by the debug extensions closing this.

@isidorn isidorn closed this as completed Sep 10, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Oct 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests