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 paste will not escape content when code has error #3761

Closed
jdneo opened this issue Sep 9, 2024 · 1 comment · Fixed by eclipse-jdtls/eclipse.jdt.ls#3268
Closed

Copy paste will not escape content when code has error #3761

jdneo opened this issue Sep 9, 2024 · 1 comment · Fixed by eclipse-jdtls/eclipse.jdt.ls#3268

Comments

@jdneo
Copy link
Collaborator

jdneo commented Sep 9, 2024

copy-paste.mp4
@rgrunber
Copy link
Member

rgrunber commented Sep 9, 2024

When the error is on the same line, there may be issues recovering the statement by the AST Parser. Ultimately, StringRangeFinder (which is just an AST Visitor) fails to visit the StringLiteral (never recovered).

Easy fix seems to be to call parser.setStatementsRecovery(true); around https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/PasteEventHandler.java#L225-L226 . It might not recover every case, but it certainly does a better job. I can put together a PR.

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.

2 participants