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

Copy value please specify the context. #69768

Closed
actboy168 opened this issue Mar 4, 2019 · 19 comments
Closed

Copy value please specify the context. #69768

actboy168 opened this issue Mar 4, 2019 · 19 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@actboy168
Copy link

https://github.com/Microsoft/debug-adapter-protocol/blob/gh-pages/debugAdapterProtocol.json#L1964-L1973

The copy value is implemented using EvaluateRequest. But now context is null. If VSCode can provide an enum for the copy value, the DA will be able to optimize it.

@weinand weinand added debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality and removed debug Debug viewlet, configurations, breakpoints, adapter issues labels Mar 4, 2019
@weinand
Copy link
Contributor

weinand commented Mar 4, 2019

I've created a protocol change request to address this issue.

@isidorn
Copy link
Contributor

isidorn commented Mar 11, 2020

@actboy168 looking at the code Copy Value shuold pass the variables context. Is that not enough for what you are looking for?

@weinand If this is not enough we should look into this so debug authors could distungish between copy value and other evaluations potentially needed for #73845

@actboy168
Copy link
Author

Thank you, Copy Value has its own context, but still a few problems.

  1. In watch view, click Copy Value does not send EvaluateRequest.
  2. In watch view, variables without variableReference do not display the UI of Copy Value. In the variables view, it just depends on whether there is an evaluateName.I think the variable view is the correct behavior.
  3. The variables context is not documented.

@isidorn
Copy link
Contributor

isidorn commented Mar 11, 2020

  1. We can fix it, so it is consistent. Currently it does not send EvaluateRequest because the watch is already evaluated
  2. This is correct behavior, watch variables require the evaluateName property, without it we do not know what we need to evaluate. We will not change this
  3. We can document it

@actboy168
Copy link
Author

For the second point, I mean that currently in the watch view, only the variable without variableReference will show Copy Value.
2

@isidorn
Copy link
Contributor

isidorn commented Mar 11, 2020

@actboy168 that is probably because the other variable do not have the evaluateName. Please provide the evaluateName and the Copy will be shown

@actboy168
Copy link
Author

actboy168 commented Mar 12, 2020

Each item is provided with evaluateName, this is the json of the DA response.

{
    "command":"variables",
    "request_seq":20,
    "type":"response",
    "seq":27,
    "body":{
        "variables":[
            {
                "namedVariables":64,
                "evaluateName":"_G._G",
                "name":"_G",
                "type":"table",
                "variablesReference":19,
                "value":"{_G=...,_VERSION='Lua 5.4',arg=...,...}",
                "indexedVariables":1
            },
            {
                "evaluateName":"_G._VERSION",
                "name":"_VERSION",
                "type":"string",
                "variablesReference":0,
                "value":"'Lua 5.4'"
            },
            {
                "namedVariables":4,
                "evaluateName":"_G.arg",
                "name":"arg",
                "type":"table",
                "variablesReference":20,
                "value":"{'4711',-1='local path=[[c:/...',-2='-e',...}",
                "indexedVariables":2
            },
            {
                "evaluateName":"_G.assert",
                "name":"assert",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.collectgarbage",
                "name":"collectgarbage",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "namedVariables":8,
                "evaluateName":"_G.coroutine",
                "name":"coroutine",
                "type":"table",
                "variablesReference":23,
                "value":"{close=func,create=func,isyieldable=func,...}",
                "indexedVariables":1
            },
            {
                "namedVariables":32,
                "evaluateName":"_G.debug",
                "name":"debug",
                "type":"table",
                "variablesReference":11,
                "value":"{debug=func,gethook=func,getinfo=func,...}",
                "indexedVariables":1
            },
            {
                "evaluateName":"_G.dofile",
                "name":"dofile",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.error",
                "name":"error",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.getmetatable",
                "name":"getmetatable",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "namedVariables":16,
                "evaluateName":"_G.io",
                "name":"io",
                "type":"table",
                "variablesReference":12,
                "value":"{close=func,flush=func,input=func,...}",
                "indexedVariables":1
            },
            {
                "evaluateName":"_G.ipairs",
                "name":"ipairs",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.load",
                "name":"load",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.loadfile",
                "name":"loadfile",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "namedVariables":32,
                "evaluateName":"_G.math",
                "name":"math",
                "type":"table",
                "variablesReference":21,
                "value":"{abs=func,acos=func,asin=func,atan=func,...}",
                "indexedVariables":1
            },
            {
                "evaluateName":"_G.next",
                "name":"next",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "namedVariables":16,
                "evaluateName":"_G.os",
                "name":"os",
                "type":"table",
                "variablesReference":17,
                "value":"{clock=func,date=func,difftime=func,...}",
                "indexedVariables":1
            },
            {
                "namedVariables":8,
                "evaluateName":"_G.package",
                "name":"package",
                "type":"table",
                "variablesReference":14,
                "value":"{config='\\\n;\n?\n!\n-\n',cpath='D:\\work\\vscode-l...',...}",
                "indexedVariables":1
            },
            {
                "evaluateName":"_G.pairs",
                "name":"pairs",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.pcall",
                "name":"pcall",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.print",
                "name":"print",
                "type":"c function",
                "variablesReference":18,
                "value":"C function"
            },
            {
                "evaluateName":"_G.rawequal",
                "name":"rawequal",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.rawget",
                "name":"rawget",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.rawlen",
                "name":"rawlen",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.rawset",
                "name":"rawset",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.require",
                "name":"require",
                "type":"c function",
                "variablesReference":22,
                "value":"C function"
            },
            {
                "evaluateName":"_G.select",
                "name":"select",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.setmetatable",
                "name":"setmetatable",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "namedVariables":32,
                "evaluateName":"_G.string",
                "name":"string",
                "type":"table",
                "variablesReference":15,
                "value":"{byte=func,char=func,dump=func,find=func,...}",
                "indexedVariables":1
            },
            {
                "namedVariables":8,
                "evaluateName":"_G.table",
                "name":"table",
                "type":"table",
                "variablesReference":16,
                "value":"{concat=func,insert=func,move=func,...}",
                "indexedVariables":1
            },
            {
                "evaluateName":"_G.tonumber",
                "name":"tonumber",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.tostring",
                "name":"tostring",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.type",
                "name":"type",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "namedVariables":8,
                "evaluateName":"_G.utf8",
                "name":"utf8",
                "type":"table",
                "variablesReference":13,
                "value":"{char=func,charpattern='[-��-�][�-�]*',...}",
                "indexedVariables":1
            },
            {
                "evaluateName":"_G.warn",
                "name":"warn",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            },
            {
                "evaluateName":"_G.xpcall",
                "name":"xpcall",
                "type":"c function",
                "variablesReference":0,
                "value":"C function"
            }
        ]
    },
    "success":true
}

@actboy168
Copy link
Author

actboy168 commented Mar 12, 2020

In addition, the value of the root node comes from EvaluateResponse, not VariablesResponse. And EvaluateResponse cannot provide evaluateName, it also does not have Copy Value. Whether the root node has Copy Value also depends on variableReference.

1
2

@isidorn
Copy link
Contributor

isidorn commented Mar 12, 2020

We have changed the watches view to be consistent now wer will always have the copy value, you can try it with vscode insiders

@weinand will push a change to the protocol such that we can set a different context when doing a copy value. See microsoft/debug-adapter-protocol#29.

@weinand
Copy link
Contributor

weinand commented Mar 12, 2020

I've created another AP feature request to document the variables context value.

@weinand
Copy link
Contributor

weinand commented Mar 12, 2020

@isidorn I've added a new value clipboard to the context enum passed to the evaluate request.
Here is the TypeScript commit with the changes.

@isidorn
Copy link
Contributor

isidorn commented Mar 13, 2020

VSCode is now respecting the capabilities.supportsClipboardContext. If this is set to true the context passed will be clipboard
@actboy168 can you try it in vscode insiders from next week and let us know if it behaves as expected now.

@isidorn isidorn self-assigned this Mar 13, 2020
@isidorn isidorn added the verification-needed Verification of issue is requested label Mar 13, 2020
@isidorn isidorn added this to the March 2020 milestone Mar 13, 2020
@actboy168
Copy link
Author

In the WATCH view, Copy Value did not send an EvaluateRequest. It appears to be the result of using Add to Watch.

@isidorn
Copy link
Contributor

isidorn commented Mar 16, 2020

@actboy168 correct that is still how we behave. We can change this though, @weinand thoughts?

@weinand
Copy link
Contributor

weinand commented Mar 16, 2020

@isidorn Since "Copy to clipboard" must result in the same value in REPL, VARIABLES and WATCHES view we should use the same EvaluateRequest in all cases.

@isidorn
Copy link
Contributor

isidorn commented Mar 16, 2020

@weinand makes sense.
I have pushed a commit which tackles this behavior. Thank you

isidorn added a commit that referenced this issue Mar 16, 2020
@isidorn
Copy link
Contributor

isidorn commented Mar 24, 2020

@actboy168 is this now behaving better for you? Asking because we would like to add a verified label here if possible.

@actboy168
Copy link
Author

Yes, it works fine now.

@isidorn
Copy link
Contributor

isidorn commented Mar 25, 2020

Great, thanks for letting us know. Adding verified label.

@isidorn isidorn added the verified Verification succeeded label Mar 25, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Apr 27, 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 verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants