You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
editor paste lags in response after large uptime #3936
Hi, sometimes after quite of time working on a maven quarkus project the pasting of text (e.g. from one file into another) takes a quite amount of time to finish.
In this example one string should be replaced by another string (the one which is selected)
The new string was visible after 4-5 seconds.
We are on the newest extension version 1.40 (happend also before).
JAVASE 21 for language Server, JAVASE 17 for the project (runtime). WIN 10.
vscode-java has a custom paste event handler that can automatically escape the content of Strings that are pasted within "...", attempt to fill in missing imports from pasted code, as well as properly set up project structure when pasting a block of code.
As a workaround, you could disable the Java extension's custom paste support by setting :
"[java]": {
"editor.pasteAs.enabled": false
},
Just to confirm. Does it always take 4-5 seconds when performing the exact same action, or only after working on the project for a long time. It would help if you set "java.trace.server": "verbose". This will generate quite a bit of logging so maybe not desired to have enabled at all times. When the problem happens again, I would open the command palette and select Java: Open Java Language Server Log File. Do you see any errors reported around the time of that 4-5s delay ? Also, if you just open the Output view, there should be a Language Support For Java entry from the dropdown (ignore the Syntax Server one). I'd be interested in any of the messages that sent a workspace/executeCommand request, with a command of java.edit.handlePasteEvent. There should be a response to that request and it would probably indicate how long the language server took to respond.
Otherwise, I am aware of some general odd behaviour the language server has where after running for some time, certain requests temporarily take longer, but often recover.
Hi @rgrunber thanks for getting back on this. I have set this setting and activated the trace. When i stumble upon this behaviour again (and i can provide more information) i will report here again...
would be expected to make the issue completely go away as it disables our paste contribution. The other setting/instructions I mentioned are more to learn more about potentially where the slowdown happens when the above setting is not present (custom paste enabled).
Hi, I'm also running into this issue, see the log traces below. The logs don't seem to provide anything useful to figure out the root cause of this though. If there's anything I can do to help, let me know.
Either way the paste handler should:
determine as quickly as possible whether it can be of any use and if not, abort immediately
time out after 1 second. There is the little cross to cancel, but the paste handler should give up much faster itself. I shouldn't have to be bothered to click the cross because the paste handler has a bug that causes it to take half a minute to do nothing different than "dumb paste" would've done
[Trace - 12:36:10 PM] Sending request 'workspace/executeCommand - (4183)'.
Params: {
"command": "java.edit.handlePasteEvent",
"arguments": [
"{\"location\":{\"range\":{\"start\":{\"line\":22,\"character\":8},\"end\":{\"line\":22,\"character\":8}},\"uri\":\"file:///c%3A/Users/.../Resources.java\"},\"text\":\"sha256:b59327fe979b1de9294b9eca3c84bcf77874e6e1b17f35b9a2da420dc3edfd76\",\"formattingOptions\":{\"insertSpaces\":true,\"tabSize\":4}}"
]
}
[Trace - 12:36:40 PM] Received response 'workspace/executeCommand - (4183)' in 30861ms.
No result returned.
[Trace - 12:36:11 PM] Sending request 'workspace/executeCommand - (4187)'.
Params: {
"command": "java.edit.handlePasteEvent",
"arguments": [
"{\"location\":{\"range\":{\"start\":{\"line\":22,\"character\":8},\"end\":{\"line\":22,\"character\":8}},\"uri\":\"file:///c%3A/Users/.../Resources.java\"},\"text\":\"sha256:b59327fe979b1de9294b9eca3c84bcf77874e6e1b17f35b9a2da420dc3edfd76\",\"formattingOptions\":{\"insertSpaces\":true,\"tabSize\":4}}"
]
}
[Trace - 12:36:40 PM] Received response 'workspace/executeCommand - (4187)' in 29919ms.
No result returned.
@rgrunber I'm no longer able to reproduce with the same string in the same file (I don't remember the exact spot). When it happens again I'll share the file exactly as it was at the time of the paste, though I doubt the bug is deterministic, i.e. that the combination of (source code, pasted text, cursor location) always reproduces the issue.
@rgrunber here's an example with the source code exactly as it was (I marked the cursor position with <cursor>). However, as expected, once it has occurred, it doesn't reproduce anymore: right after it occurred I pressed Ctrl+Z and Ctrl+V, but this time the result was instant.
[Trace - 6:10:59 PM] Sending request 'workspace/executeCommand - (16661)'.
Params: {
"command": "java.edit.handlePasteEvent",
"arguments": [
"{\"location\":{\"range\":{\"start\":{\"line\":20,\"character\":12},\"end\":{\"line\":20,\"character\":12}},\"uri\":\"file:///c%3A/Users/.../ListChangedModules.java\"},\"text\":\"\\\"%s-%s\\\".formatted(path.getName(2), path.getName(3))\",\"copiedDocumentUri\":\"file:///c%3A/Users/.../ListChangedModules.java\",\"formattingOptions\":{\"insertSpaces\":true,\"tabSize\":4}}"
]
}
[Trace - 6:11:02 PM] Received response 'workspace/executeCommand - (16661)' in 2915ms.
No result returned.
UX around this could definitely be improved. I was confused as to why simple text pastes were taking so long, so I tried Ctrl-Shift-V instead, which as we all know is a common "just paste the clipboard without extra magic" shortcut. That avoids the paste delay ✅, but apparently also re-organizes the imports?! 💀 I've been falsely accusing poor Copilot of these crimes for weeks while restoring imports for my PRs from git history...
I've found that applying "java.updateImportsOnPaste.enabled": false seems to have solved this issue for me, albeit I've only had that applied for approximately 45 minutes so far.
PS Context for me:
Extension version 1.54.0
Largish project with approximately 1600 classes, including some ANTLR4 generated ones
Activity
[-]Lag of Languageserver[/-][+]editor paste lags in response after large uptime[/+]rgrunber commentedon Feb 5, 2025
vscode-java has a custom paste event handler that can automatically escape the content of Strings that are pasted within
"...", attempt to fill in missing imports from pasted code, as well as properly set up project structure when pasting a block of code.As a workaround, you could disable the Java extension's custom paste support by setting :
Just to confirm. Does it always take 4-5 seconds when performing the exact same action, or only after working on the project for a long time. It would help if you set
"java.trace.server": "verbose". This will generate quite a bit of logging so maybe not desired to have enabled at all times. When the problem happens again, I would open the command palette and selectJava: Open Java Language Server Log File. Do you see any errors reported around the time of that 4-5s delay ? Also, if you just open theOutputview, there should be aLanguage Support For Javaentry from the dropdown (ignore the Syntax Server one). I'd be interested in any of the messages that sent aworkspace/executeCommandrequest, with a command ofjava.edit.handlePasteEvent. There should be a response to that request and it would probably indicate how long the language server took to respond.Otherwise, I am aware of some general odd behaviour the language server has where after running for some time, certain requests temporarily take longer, but often recover.
kraabrsg commentedon Feb 7, 2025
Hi @rgrunber thanks for getting back on this. I have set this setting and activated the trace. When i stumble upon this behaviour again (and i can provide more information) i will report here again...
rgrunber commentedon Feb 7, 2025
Just be aware that
would be expected to make the issue completely go away as it disables our paste contribution. The other setting/instructions I mentioned are more to learn more about potentially where the slowdown happens when the above setting is not present (custom paste enabled).
anthonyvdotbe commentedon Jun 17, 2025
Hi, I'm also running into this issue, see the log traces below. The logs don't seem to provide anything useful to figure out the root cause of this though. If there's anything I can do to help, let me know.
Either way the paste handler should:
rgrunber commentedon Jun 17, 2025
@anthonyvdotbe , does this happen consistently in the same file ? At the same spot ? Are you able to share the source file where this happens ?
anthonyvdotbe commentedon Jun 17, 2025
@rgrunber I'm no longer able to reproduce with the same string in the same file (I don't remember the exact spot). When it happens again I'll share the file exactly as it was at the time of the paste, though I doubt the bug is deterministic, i.e. that the combination of (source code, pasted text, cursor location) always reproduces the issue.
anthonyvdotbe commentedon Jun 20, 2025
@rgrunber here's an example with the source code exactly as it was (I marked the cursor position with
<cursor>). However, as expected, once it has occurred, it doesn't reproduce anymore: right after it occurred I pressedCtrl+ZandCtrl+V, but this time the result was instant.srstsavage commentedon Aug 29, 2025
UX around this could definitely be improved. I was confused as to why simple text pastes were taking so long, so I tried Ctrl-Shift-V instead, which as we all know is a common "just paste the clipboard without extra magic" shortcut. That avoids the paste delay ✅, but apparently also re-organizes the imports?! 💀 I've been falsely accusing poor Copilot of these crimes for weeks while restoring imports for my PRs from git history...
gregorywilliams commentedon Jun 7, 2026
I've found that applying
"java.updateImportsOnPaste.enabled": falseseems to have solved this issue for me, albeit I've only had that applied for approximately 45 minutes so far.PS Context for me: