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

Add "Copy as..." from debug extensions #188604

Closed
zobo opened this issue Jul 23, 2023 · 9 comments
Closed

Add "Copy as..." from debug extensions #188604

zobo opened this issue Jul 23, 2023 · 9 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality

Comments

@zobo
Copy link
Contributor

zobo commented Jul 23, 2023

Hi all!

I was wondering if there were a way for a debugger extension to influence the debugger windows. In reference to this issue xdebug/vscode-php-debug#400 I was wondering if the PHP Debug extension could somehow register additional context options when a user right clicks on a variable to copy its value. I'd like to add context menu items like "Copy Value as JSON" and "Copy Value as var_export" and then have these commands send a DAP evaluateRequest with a specific, custom, context instead of clipboard. Like clipboard-json...

This could probably be achieved in a declarative way through the manifest (very issue specific) or some hooks in the extension code (more general approach).

Thanks!

@roblourens
Copy link
Member

An extension can register a command on the variables tree context menu, which has the ID debug/variables/context. Then it could send the evaluate request or another custom request itself with whatever arguments needed. That is how we support custom vscode-specific behavior like this. Does that help?

@roblourens roblourens added the info-needed Issue requires more information from poster label Jul 24, 2023
@zobo
Copy link
Contributor Author

zobo commented Jul 24, 2023

Yes, looks good. I'm digging around to get the right types, but I think I can work with this.

I've spoke too soon.

First I register the menu, this works:

    "menus": {
      "debug/variables/context": [
        {
          "command": "php.debug.testctx",
          "group": "5_cutcopypaste@20"
        }
      ]
    },
    "commands": [
      {
        "command": "php.debug.testctx",
        "title": "Copy Value as var_export"
      }

I then register the command:

    context.subscriptions.push(
        vscode.commands.registerCommand('php.debug.testctx', async (arg: IVariablesContext, p2:any, p3:any) => {
            await vscode.debug.activeDebugSession?.customRequest('evaluate', <DebugProtocol.EvaluateArguments>{
                context: 'clipboard-wtf',
                expression: arg.variable.evaluateName,
                // frameId: vscode.debug.stackFrameFocus
            })

I used this code to model the command

CommandsRegistry.registerCommand({

The IVariablesContext is a private interface, I had to copy it.
There seems to be no way to find out what the current selected stack frame that is needed for the EvaluateArguments.
There is an unexposed vscode.debug.stackFrameFocus and I found this issue: #63943

Am I going about this the right way?

Thanks!

@vscodenpa
Copy link

Hey @roblourens, this issue might need further attention.

@zobo, you can help us out by closing this issue if the problem no longer exists, or adding more information.

@zobo
Copy link
Contributor Author

zobo commented Oct 13, 2023

Hi @VSCodeTriageBot ! ;)

Not sure if there was any API change, but the last time I checked there were some public API interfaces missing that prevented me from implementing this desired feature.

I have not worked on it in a while and not sure if I will implement it like this - however the referenced task that also deals with the underlying issue will hopefully be moved forward. In this light the current task could potentially be closed as a duplicate or left open as "depends on".

@zobo
Copy link
Contributor Author

zobo commented Oct 13, 2023

Nevertheless it would be great to get a definitive reply if I am correctly interpreting the API code.

@roblourens
Copy link
Member

Yeah, that is not exposed right now. I guess it should be on that context object, or exposed as in #63943

@roblourens roblourens added feature-request Request for new features or functionality debug Debug viewlet, configurations, breakpoints, adapter issues and removed info-needed Issue requires more information from poster labels Dec 15, 2023
@vscodenpa vscodenpa added this to the Backlog Candidates milestone Dec 15, 2023
@vscodenpa
Copy link

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@vscodenpa
Copy link

This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@vscodenpa
Copy link

🙁 In the last 60 days, this feature request has received less than 20 community upvotes and we closed it. Still a big Thank You to you for taking the time to create this issue! To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@vscodenpa vscodenpa closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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

3 participants