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

Can we have actions to copy an expression's full value? #1474

Open
foxt451 opened this issue Mar 17, 2025 · 3 comments
Open

Can we have actions to copy an expression's full value? #1474

foxt451 opened this issue Mar 17, 2025 · 3 comments

Comments

@foxt451
Copy link

foxt451 commented Mar 17, 2025

Problem Statement

I saw there is an action in the hover widget "Copy as expression", which copies the field's path (I'm talking about vtsls, but I guess it works the same everywhere), but it would be great to be able to copy the expression's value itself (especially when it's a very long string, which gets truncated with an ellipsis somewhere in the middle - both in repl and hover).

Possible Solutions

With repl I currently use sth like this

custom_commands = {
          ['.copy'] = function(text)
            local evaluated = repl.execute(text, {
              context = 'clipboard',
            })
            -- vim.fn.setreg(register, response.result)
          end,
        },

and with hover widget actions I guess it would be similar - just add an action that copies the expression with clipboard context

Considered Alternatives

No response

@mfussenegger
Copy link
Owner

Relates a bit to #1062

especially when it's a very long string, which gets truncated with an ellipsis somewhere in the middle - both in repl and hover

I'm a bit confused about this - there's currently no trimming happening for the value/result of the evaluate or variable responses.

The most what a "Copy value" could do would be to avoid having to skip the name part. E.g. in:

dap> statement
"Foobar"
  coder: 0
  hash: 0
  hashIsZero: false
  value: byte[6]@59

If the cursor is on hash it could copy the 0.
But without language specific hooks/extensions it for example can't copy the value as some sort of byte literal but will also only copy byte[6]@59 instead of something like 46 6f 6f 62 61 72

@foxt451
Copy link
Author

foxt451 commented Mar 18, 2025

Thanks for reply!

there's currently no trimming

I think it might be tsserver-specific - basically, without clipboard context it will insert an ellipsis (see pic) somewhere in the line, if it is too long (both in repl, hover and everywhere)

The most what a "Copy value" could do would be to avoid having to skip the name part

Not sure if I understand you here - with the current "Copy as expression" (I'm talking about the one on pic2) only the name part is copied (e.g. reponse.url instead of the actual URL), even if the cursor is on the value, so you can't avoid it, and so effectively can't copy the value itself (and when the hover is on just a value variable, not an object's property, there are no available actions)

But without language specific hooks/extensions it for example can't copy the value as some sort of byte literal but will also only copy byte[6]@59 instead of something like 46 6f 6f 62 61 72

I haven't had such a use-case, I just copy strings mostly, but I guess a user could go to repl to get a better format then

Image Image

@mfussenegger
Copy link
Owner

I think it might be tsserver-specific - basically, without clipboard context it will insert an ellipsis (see pic) somewhere in the line, if it is too long (both in repl, hover and everywhere)

That's good information, thanks. I wasn't aware that some adapters do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants