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

Make custom pasting less eager #3444

Closed
fbricon opened this issue Dec 25, 2023 · 4 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#3016
Closed

Make custom pasting less eager #3444

fbricon opened this issue Dec 25, 2023 · 4 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#3016

Comments

@fbricon
Copy link
Collaborator

fbricon commented Dec 25, 2023

In JBang VS Code, I have my own paste provider to convert Maven XML dependencies into JBang //DEPS. Now that vscode-java provides its own provider, it takes over and makes the experience less pleasant:

Screenshot 2023-12-25 at 18 05 25

IMO, vscode-java should be more clever and do not return a DocumentPasteEdit if no special handling is necessary (eg. pasted content is not java, or pasting site is not within String quotes.

@rgrunber
Copy link
Member

Interestingly, the vscode-java contributed paste edit isn't always present. If I paste xml within the type declaration, the vscode-java paste edit is never created. However, when done in the import area, it is. I think this might actually be a bug in the language server.

null is returned when pasting within the type declaration :

https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/2b7857b1fbc3ff35f7c126c6e7dadb53665977e9/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/PasteEventHandler.java#L336-L338

the original paste text is returned in a lot of "failing" cases, or if we're not within a type declaration :

https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/2b7857b1fbc3ff35f7c126c6e7dadb53665977e9/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/PasteEventHandler.java#L286-L301

So we probably need to try returning null everywhere, and that probably fixes it.

// either the handler returns null or encounters problems, fall back to return undefined to let VS Code ignore this handler
return undefined;

The client is already set up to ignore the handler if the delegate doesn't return anything.

@rgrunber
Copy link
Member

rgrunber commented Jan 4, 2024

@hopehadfield , interested in this ? Should be easy to fix, but just requires a bit of verifying the desired behaviour.

@rgrunber
Copy link
Member

rgrunber commented Jan 11, 2024

@hopehadfield , are you able to reproduce the behaviours described in (without the PR that fixed this) :

#3445, #3236, #3237, #3164 . Does this fix them ?

Update: I think it does! 😎

@hopehadfield
Copy link
Contributor

@rgrunber I could reproduce everything except for the issues relating to multi-cursor paste (those seemed to work fine for me even without this PR). This fixed all the other issues for me though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants